Get the colours of each pixel of an image.

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Elisabet
Newbie
Newbie
Posts: 22
Joined: Fri Nov 15, 2002 12:00 am
Location: Madrid

Get the colours of each pixel of an image.

Post by Elisabet » Fri Oct 21, 2005 11:18 am

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,

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Oct 21, 2005 2:37 pm

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply