Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
S

Stephane David

@Stephane David
About
Posts
35
Topics
14
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Capturing a perticular part of an Image
    S Stephane David

    You can also use Bitmap.Clone. It lay you specify a rectangle, which is the part of the image. With Clone, the resulting image will keep the PixelFormat of the source. For instance, if your first image is 8 bits per pixel, indexed, the cloned image will be also. If you use the other method, with DrawImage, the image must be at least 16bpp I think.

    C# tutorial

  • multiframe gif
    S Stephane David

    http://www.dotnet247.com/247reference/msgs/28/140380.aspx it seems only the TIFF encoder supports multipages...

    C# tutorial question

  • multiframe gif
    S Stephane David

    It doesn't work. preview.Save(fileName, myImageCodecInfo, myEncoderParameters); // OK preview.SaveAdd(frame,null); // Wrong parameters used (sorry, the exact error message is in French). I've tried to use null for myEncoderParameters in the Save, same result Also same result if I don't use the CodecInfo at all. The code works with TIFF. Not with gif. Any idea?

    C# tutorial question

  • multiframe gif
    S Stephane David

    I'm trying to maje an animation using gif. I have several frames that I want to save inmy gif file, using the SaveAdd function. But I cannot find anywhere example or documentation about the gif encoder. Can someone give my an example of how to do it, or direct me to some example? I have found only info for Tiff.

    C# tutorial question

  • Strange GDI+ error
    S Stephane David

    I have a storyboard, a single image that contains several frames. My program cut this storyboard in individual frames, of variable size. I now want to save these individual frames in separate files. This part works. The gif are indeed saved. Later I need to make copies of some of these files, after I've done some processing on memory on them. So I start by loading the individual frames doing Bitmap bitmap = new Bitmap("Frame1.gif"); // Then some processing // Then I save it again bitmap.Save("Frame1.gif", PixelFormat.gif); And there it crashes. I have tried to do the save immediatly after the load, in case my processing was messing something, but it still doesn't work. Conclusion: I cannot save a bitmap immediately after I load it? :confused:

    C# graphics help winforms question

  • Serialization and versionning
    S Stephane David

    I'm developping an application where I need to serialize objects. But the properties of these objects may change during the developpment as I could add new options. For instance, I may have this class Car { // version1 string ModelName; int Speed_Mph; } And then I want to serialize an array of Car into a binary file (foo.sav) Later, I add the color : class Car { // version1 string ModelName; int Speed_Mph; // version 1.1 string Color; } Now, if I try to used the deserialization function with foo.sav, it won't work, because foo.sav didn't contain the Color properties for Car. What is the easiest / msot efficient way to solve it? I have several ideas in mind, but I don't know the better ones. The most efficient one seems to be to write my own ISerializable interface, and start by reading the version. It works, but I'm afraid it's a lot of work, as I need to assign the keys one by one, needn't I?

    C# question data-structures json performance announcement

  • Working with pixels and palette
    S Stephane David

    Sorry if I was a bit offensive. Your solution works, but not in my particular case, because it is quite likely that the palette contains several identical colors, and there should be used as different color by the software.

    C# question csharp database winforms graphics

  • Working with pixels and palette
    S Stephane David

    I've found a solution to one of my problem. Bitmap.Palette return a copy of the palette. So I need to do ColroPalette palette = bmp.Palette; palette.Entries[0] = Color.FromArgb(150,255,255,255); bmp.Palette = palette; And then it works, even for the alphablending, and the picture is 8bpp indexed, it doesn't need to the 32-bit color. However, your solution to get the index of a pixel will not work, as I can have several indexes in the palette with the same color, but they must be processed differently. For instance, the last index is the background color and must be 100% transparent. But if it is magenta, and the 76th index is also magenta, then only the background must become transparent, and the 76th inndex must remain magenta

    C# question csharp database winforms graphics

  • Working with pixels and palette
    S Stephane David

    Thanks for the answer, but it won't work. I know that in the palette the last index is the transparency color, whatever the actual color. It is usually magenta, but it could be something else. And if it is Magenta, but the first color is also magenta, then only some pixels (last index) must be transparent, the other one (first index) must remain magenta. That's why I'd like to get the actual index, and not only the color

    C# question csharp database winforms graphics

  • ColorPalette class
    S Stephane David

    How can it be used? The only thing I can do is retrieve the colors in the Entries. How can I change them? I'd like to change the palette of a 256 color gif. So I have Bitmap MyBitmap = new Bitmap("file.gif"); I tried MyBitmap.Palette.Entries[0] = Drawing.Color.Black, but it does nothing as Entries is a read only properties. How can I change the palette entries? Or how can I create a new ColorPalette? Bitmap.Palette is a read / write property, but there is no constructor for the ColorPalette class, and the ColorPalette.Entries are read only :confused:

    C# graphics question

  • Working with pixels and palette
    S Stephane David

    Hello, I'm trying to program a "clone" of civilization III, using only C# and GDI+ (kind of exercice to learn). I've manage to make a functional map and map editor, and I'm trying to animate the sprites. It works, except for two things : shadows and player color. My animation are 256 colors storyboard. I know that the last 20 indexes are used for shadows. Question 1: how can I know with C# and GDI+ what is the index in the palette of a pixel? The GetPixel function gives the color, not the index. Question 2 : How can I use an alphablending effect, but only on some indexes of the palette? Is it possible? Question 3 : for player color, how can I replace the 10th index color in the palette by another color? Supposing player color is the 10th index of course. Thanks

    C# question csharp database winforms graphics

  • Using Word with C#
    S Stephane David

    After many testing, I've discovered that it didn't work because of my Office XP. I have installed Office 2000 instead, and now it works. Except for one thing. I'd like to replace text which is a TextBox, and not in the body of the document. But Word.Content doesn't include shapes apparently. Anyone with an idea?

    C# csharp com data-structures help question

  • Using Word with C#
    S Stephane David

    That was on purpose. As the replace doesn't work, I've tried the very basic, with the simpliest exemple I could find in the library, just find a text. And I still get the exception. In this exemple, they do not use a parameter, but Word.Find.Text instead

    C# csharp com data-structures help question

  • Using Word with C#
    S Stephane David

    Arggh!!!! :mad: I'm using this simple exemple directly from the article you linked for me. And it still doesn't work!!! Would there be something else? Like not a simple parameter error, but perhaps a difference if I'm using Office XP or Windows XP? // C# internal void SelectionFind() { string strFind = "find me"; Word.Find fnd = ThisApplication.Selection.Find; fnd.ClearFormatting(); fnd.Text = strFind; object missingValue = Type.Missing; if (fnd.Execute(ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue)) { MessageBox.Show("Text found."); } else { MessageBox.Show("The text could not be located."); } }

    C# csharp com data-structures help question

  • Using Word with C#
    S Stephane David

    Ok... I've tried to use an ActiveDocument.Content. I've tried with Selection. I've tried using Missing.Value with several parameters. Nothing works. I always get the same error... The execption starts to be not very... exceptional... And to close the topic of exception, I never said I don't want to handle an exception. I said I don't know how to correct this one. Right now, my function always raise an exception, so it is useless....

    C# csharp com data-structures help question

  • Using Word with C#
    S Stephane David

    That's what I meant. In that case, the only information I can provide the user with is "this function doesn''t work, and I don't know how to make it work". If the error happens 100% of the time, then is it not an exception, it really is a programming error. It doesn't prevent me from handling the exception, but it is not a solution to my problem.

    C# csharp com data-structures help question

  • Using Word with C#
    S Stephane David

    Thank you for your answer. I agree that user should never see an exception, but I think it is even better to write correct code and avoid the exception, rather than displaying the error message. Exception would be nice if for instance the .dot file doesn't exist, but here it seems to be different. About the empty : the Find.Execute function takes 15 parameters. The VBA help of Word gives me the feeling that none are supposed to be empty, but false. I have tried to use empty with some of these parameters, that are supposed to be facultative, but it changed nothing. So I'm in need of more specific solution. About the naming convention: I usually don't use hungarian notation, except in two cases. First, to differentiate between some parameters (like if I have a member Param, and a parameter Param), or when I'm porting an old C++ code, which is the case here, and I forget to rename a few classes or function.

    C# csharp com data-structures help question

  • Using Word i nC#
    S Stephane David

    I've tried to used this article http://www.codeproject.com/csharp/CsAutomateWord.asp?target=Word to create a character sheet. I have a CCharacter class, that contains all information about a character, and I want to generate a MS Word document with these information. So I've created .dot document, with thinks like Name _Name_ Age _Age_ in arrays (I've tried also without the array, directly in the text). _XXX_ is code that I will use for replacement. Now, to the code: // Create a Word application Word.ApplicationClass vk_word_app = new Word.ApplicationClass(); // Open the .dot object FileName =Directory.GetCurrentDirectory()+"\\Models\\Sheet.dot"; Word.Document vk_my_doc = vk_word_app.Documents.Open(... // Create a new document Word.Document vk_new_doc = vk_word_app.Documents.Add((... // Copy the .dot into the new document vk_my_doc.Select(); vk_word_app.Selection.Copy(); vk_new_doc.Select(); vk_word_app.Selection.PasteAndFormat(Word.WdRecoveryType.wdPasteDefault); // close the .dot vk_my_doc.Close( ref vk_false, ref vk_missing, ref vk_missing ); All the previous steps work. I get a new document, build from my template. Now, I'd like to fill it with actual information. So I do this // Select the new doc vk_new_doc.Select(); // Define some variable object vk_false = false; object vk_true = true; object vk_num = Word.WdFindWrap.wdFindStop; object vk_find = "_Nom_"; object vk_replaceWith = Name_Familly; // This one is a member of CCharacter class object vk_replace = Word.WdReplace.wdReplaceOne; // Try to replace the text vk_word_app.Selection.Find.Execute( ref vk_find, ref vk_false, ref vk_false, ref vk_false, ref vk_false, ref vk_false, ref vk_true, ref vk_num, ref vk_false, ref vk_replaceWith, ref vk_replace, ref vk_false, ref vk_false, ref vk_false, ref vk_false ); And... it doesn't work. I got this error: System.Runtime.InteropServices.COMException (0x800706F7): Le relais a reçu des données incorrectes. at Word.Find.Execute(Object& FindText, Object& MatchCase, Object& MatchWholeWord, Object& MatchWildcards, Object& MatchSoundsLike, Object& MatchAllWordForms, Object& Forward, Object& Wrap, Object& Format, Object& ReplaceWith, Object& Replace, Object& MatchKashida, Object& MatchDiacritics, Object& MatchAlefHamza, Object& MatchControl) My form close, the word doc stays opened. "Le relais a reçu des données incorrectes" would translate as "incorrect data received". Any idea of a way to solve this would

    COM csharp com data-structures help question

  • Using Word with C#
    S Stephane David

    I've tried to used this article http://www.codeproject.com/csharp/CsAutomateWord.asp?target=Word to create a character sheet. I have a CCharacter class, that contains all information about a character, and I want to generate a MS Word document with these information. So I've created .dot document, with thinks like Name _Name_ Age _Age_ in arrays (I've tried also without the array, directly in the text). _XXX_ is code that I will use for replacement. Now, to the code: // Create a Word application Word.ApplicationClass vk_word_app = new Word.ApplicationClass(); // Open the .dot object FileName =Directory.GetCurrentDirectory()+"\\Models\\Sheet.dot"; Word.Document vk_my_doc = vk_word_app.Documents.Open(... // Create a new document Word.Document vk_new_doc = vk_word_app.Documents.Add((... // Copy the .dot into the new document vk_my_doc.Select(); vk_word_app.Selection.Copy(); vk_new_doc.Select(); vk_word_app.Selection.PasteAndFormat(Word.WdRecoveryType.wdPasteDefault); // close the .dot vk_my_doc.Close( ref vk_false, ref vk_missing, ref vk_missing ); All the previous steps work. I get a new document, build from my template. Now, I'd like to fill it with actual information. So I do this // Select the new doc vk_new_doc.Select(); // Define some variable object vk_false = false; object vk_true = true; object vk_num = Word.WdFindWrap.wdFindStop; object vk_find = "_Nom_"; object vk_replaceWith = Name_Familly; // This one is a member of CCharacter class object vk_replace = Word.WdReplace.wdReplaceOne; // Try to replace the text vk_word_app.Selection.Find.Execute( ref vk_find, ref vk_false, ref vk_false, ref vk_false, ref vk_false, ref vk_false, ref vk_true, ref vk_num, ref vk_false, ref vk_replaceWith, ref vk_replace, ref vk_false, ref vk_false, ref vk_false, ref vk_false ); And... it doesn't work. I got this error: System.Runtime.InteropServices.COMException (0x800706F7): Le relais a reçu des données incorrectes. at Word.Find.Execute(Object& FindText, Object& MatchCase, Object& MatchWholeWord, Object& MatchWildcards, Object& MatchSoundsLike, Object& MatchAllWordForms, Object& Forward, Object& Wrap, Object& Format, Object& ReplaceWith, Object& Replace, Object& MatchKashida, Object& MatchDiacritics, Object& MatchAlefHamza, Object& MatchControl) My form close, the word doc stays opened. "Le relais a reçu des données incorrectes" would translate as "incorrect data received". Any idea of a way to solve this would

    C# csharp com data-structures help question

  • Template and message map
    S Stephane David

    In my application, I'm using template controls to change the font and colors of any of my MFC controls. As I need some messages, I have a message map like that. BEGIN_TEMPLATE_MESSAGE_MAP(class BASE_TYPE, CColorCtrl, BASE_TYPE) //BEGIN_MESSAGE_MAP(class BASE_TYPE, CColorCtrl, BASE_TYPE) //{{AFX_MSG_MAP(CColorCtrl) ON_WM_CTLCOLOR_REFLECT() ON_WM_CTLCOLOR() ON_WM_DESTROY() ON_WM_TIMER() ON_WM_CREATE() //}}AFX_MSG_MAP END_TEMPLATE_MESSAGE_MAP() The BEGIN_TEMPLATE_MESSAGE_MAP macro is defined here. #define BEGIN_TEMPLATE_MESSAGE_MAP(theTemplArgs, theClass, baseClass) \ template \ const AFX_MSGMAP* PASCAL theClass::_GetBaseMessageMap() \ { return &baseClass::messageMap; } \ template \ const AFX_MSGMAP* theClass::GetMessageMap() const \ { return &theClass::messageMap; } \ template \ AFX_COMDAT AFX_DATADEF const AFX_MSGMAP theClass::messageMap = \ { &theClass::_GetBaseMessageMap, &theClass::_messageEntries[0] }; \ template \ AFX_COMDAT const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = \ { \ My pb is I get an error message saying that "_GetBaseMessageMap" is not a member of CColorCtrl. The code was working with Visual Studio 6.0, but does no longer work with Visual Studio .Net How can I port it to .Net?

    ATL / WTL / STL csharp question c++ delphi visual-studio
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups