Board index » cppbuilder » Problems Coloring a TBitamp

Problems Coloring a TBitamp

Hi,

I am using a TColorDialog dialog to select a color. I then draw a circle
on a Bitmap that is displayed in a TImage. Using the code below.

Image1->Canvas->Pen->Mode = pmCopy;
Image1->Canvas->Pen->Color = ColorDialog1->Color;
Image1->Canvas->Ellipse(X1,Y1,X2,Y2);

Some off the colors are displayed in a darker shade. What am I doing
wrong and how do I get around this?

Thanks,
Liam Mullane.

 

Re:Problems Coloring a TBitamp


Liam,

Quote
> Image1->Canvas->Pen->Mode = pmCopy;
> Image1->Canvas->Pen->Color = ColorDialog1->Color;
> Image1->Canvas->Ellipse(X1,Y1,X2,Y2);

> Some off the colors are displayed in a darker shade. What am I doing
> wrong and how do I get around this?

What is the color-depth of the Image's underlying bitmap?  If the bitmap
is using only, say, 8 bits per pixel, then anything that you draw to the
bitmap will be limited to those colors in the bitmap's color table.  You
can avoid this by explicitly setting the
Image::Picture::Bitmap::PixelFormat property...

   Image1->Picture->Bitmap->PixelFormat = pf24bit;

Good luck,
--
Damon Chandler (TeamB)
- BCBCAQ <http://bcbcaq.freeservers.com>
- Graphics API Black Book <http://graphicsBB.itgo.com>

Other Threads