all groups > dotnet drawing api > october 2003 >
You're in the

dotnet drawing api

group:

Cant get correct colour using System.Drawing


Cant get correct colour using System.Drawing MLynch
10/29/2003 2:36:29 PM
dotnet drawing api: Hi,

I want to fill a rectangle with a custom colour (purple-ish). however when
the generated gif file is viewed the colour in the rectangle is stippled
which seems to me to indicate it saved in as a low res colour. (Sample code
below)

What am I missing here? Do I need to work with Bitmap palettes?

Regards

- M Lynch

Bitmap bitmap = new Bitmap(100, 100, PixelFormat.Format32bppRgb);
Graphics graphics = Graphics.FromImage(bitmap);
graphics.FillRectangle(new SolidBrush(Color.FromArgb(82, 56, 91)), 0, 0,
100, 100);

bitmap.Save("a.gif", ImageFormat.Gif);
graphics.Dispose();
bitmap.Dispose();









Re: Cant get correct colour using System.Drawing Bob Powell [MVP]
10/29/2003 3:50:36 PM
GIF files are always saved with a default palette that consists of a
specific set of colours. You will have to modify the original palette if you
want to use this exact shade.

The GDI+ FAQ has an articly on setting the transparent colours in a GIF that
shows the standard palette and how to modify it. You should be able to
modify the provided code to create a palette with the exact shade you need.

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

The October edition of Well Formed is now available.
Find out how to use DirectX in a Windows Forms control
http://www.bobpowell.net/currentissue.htm

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

Blog http://bobpowelldotnet.blogspot.com

[quoted text, click to view]

RE: Cant get correct colour using System.Drawing JHornick NO[at]SPAM online.microsoft.com
10/29/2003 5:12:28 PM
Hi,

See the following KB articles:
http://support.microsoft.com/?id=319061
http://support.microsoft.com/?id=318343

Thanks,
- John
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Visit http://www.microsoft.com/security for current information on security.





[quoted text, click to view]
AddThis Social Bookmark Button