GDI color vs GDI+ color

  • Thread starter Thread starter pixel
  • Start date Start date
P

pixel

hi

GDI ExtFloodFill doesn't "see" GDI+ colors
..ToArgb() doesn't work at all

any suggestions

br
pixel

sample code
Graphics

gIm = Graphics.FromImage(im);

gIm.DrawEllipse(new Pen(Color.Red), 10, 10, 50, 50);

IntPtr

hIm = gIm.GetHdc(),

hBitmap = CreateCompatibleBitmap(hIm, 100, 100),

hDC = CreateCompatibleDC(hIm);

IntPtr

hOldBitmap = SelectObject(hDC, hBitmap);

BitBlt(hDC, 0, 0, 100, 100, hIm, 0, 0, SRCCOPY);

IntPtr

hOldBrush = SelectObject(hDC, GetStockObject(GRAY_BRUSH));

ExtFloodFill(hDC, e.X, e.Y, Color.Red.ToArgb(), FLOODFILLBORDER);

SelectObject(hDC, hOldBrush);

BitBlt(hIm, 0, 0, 100, 100, hDC, 0, 0, SRCCOPY);

SelectObject(hDC, hOldBitmap);

DeleteDC(hDC);

gIm.ReleaseHdc(hIm);
 
Use the ColorTranslator to create a GDI compatible COLORREF from the .NET
Color structure.

--
Bob Powell [MVP]
Visual C#, System.Drawing

The Image Transition Library wraps up and LED style instrumentation is
available in the June of Well Formed for C# or VB programmers
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml
 
Hi,

If i worked with OLE_COLOR then it have required
inversion of GDI+ RGB.

You can do it easily by:

uint uColor=(uint)( (color.B<<16) | (color.G<<8) | color.R );

If this code doesn't solve your problem then only i can
blame the BITMAP pixel format (different than 32/24 bpp).

Regards

Marcin
 
thanx man
that's why i like groups :)
there is many ways to solve a problem

btw
dzieki marcin :))

pixel
 
Back
Top