Page 1 of 1

Get the colours of each pixel of an image.

Posted: Fri Oct 21, 2005 11:18 am
by 8438229
I’m trying to draw the black line of a map above a TColorGridSeries. I’d like to convert a .bmp image into a ColorGridSeries but it doesn’t work. It only works if the image is .jpg. I use C++ Builder 6. The code that I use is:

Graphics::TBitmap *tmp = new Graphics::TBitmap();
try
{
tmp->Assign(Image1->Picture->Graphic);
Series2->Bitmap=tmp;
}
__finally
{
delete tmp;
}

When I do it, the image appears inverted. How could I correct it?

Moreover, I’d like to make transparent all the map but the black line. When I set the white colour to transparent some pixels in grey appear that I can’t delete. Can I index to every pixel to the image by ‘x’ and ‘z’ and know which colour it has? I tried GetXZValue(x,z) and ValueColor, in this case it doesn’t work.

How could I write in code this?
If (pixel[x,z] is different to colour black) set to transparent colour.

Thanks for everything,

Posted: Fri Oct 21, 2005 2:37 pm
by narcis
Hi Elisabet,

There's an example of that at TeeChart features demo, which is avaiable at TeeChart's program group. You should run the features demo and browse the "ColorGrid Bitmap" example. You'll find it at "All Features\Welcome!\Chart Styles\Statistical\Color Grid\ColorGrid Bitmap".

If you want the image being displayed in a 3D style according to its colours, double click on the yellowish explanation area to enter the chart editor and change the series from a TColorGridSeries to a TSurfaceSeries. This will do what you request.

Be careful to test it first with small images because the algorithm has geometric eficiency.