Re:RGB off Bitmap
Quote
bill wrote:
> I have the Bitmap loaded (Thanks to all who helped), but I can't seem to
> get the correct rgb info off of scanLine. Some of the sample data looks
> like this . . . Where I'm I going wrong?
> 81b7cae0 81b7cae0 81b7cae0 81b7cae0 81b7cae0 81b7cae0 81b7cae0
> 81b7cae0 81b7cae0 81b7cae0 81b7cae0 81b7cae0 81b7cae0 81b7cae0
> 81b7cae0 81b7cae0 81b7cae0 81b7cae0
<snip>
Here's what I would do (please ignore anything that's not applicable):
-------------------------------------------------------
Graphics::TBitmap* pBitmap=new Graphics::TBitmap;
byte* linePtr,*pixelPtr;
char outString[256];
pBitmap->LoadFromFile("ng.bmp");
pBitmap->PixelFormat=pf24bit;
for (int y = 0; y < pBitmap->Height; y++)
{
linePtr = (byte *)pBitmap->ScanLine[y];
for (int x = 0; x < pBitmap->Width; x++)
{
pixelPtr = linePtr+3*x;
sprintf(outString, "R: %d G: %d B: %d", pixelPtr[2], pixelPtr[1],
pixelPtr[0]);
}
}
Canvas->Draw(0,0,pBitmap);
delete pBitmap;
------------------------------------------------------
From looking at your code,
ptr[x] = (Byte)y;
You were writing into the bitmap. I haven't tried writing the results
to somewhere I can look at them; I just looked at the results with the
de{*word*81} (that's why I used sprintf).
There's some examples on my site that use ScanLine if you need them -
just go to the C++ Builder section.
Hope this helps,
Alan McIntyre
a...@norfolkgraphics.com
http://norfolkgraphics.com