 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
RandomAccess Guest
|
Posted: Sat Apr 01, 2006 6:03 pm Post subject: Need help with Bitmap Memory addressing |
|
|
I think, but am unsure, that I have problems with these declarations :
PRGB_Quad_Array = ^TRGB_Quad_Array;
TRGB_Quad_Array = Array[WORD] of TRGBQuad;
Does this imply the bitmap number of pixels must not exceed the 16bit WORD
range?
If so, what is the correct declaration for TRGB_QuadArray in order to
access pixels in a bitmap that is 2 megabytes in size or more.
Currently, the code that is AVing looks like this :
Result := fBits[X + (Y * fWidth)];
fBits is memory address of first pixel (Bmp.ScanLine[0])
I am using Delphi Pro 5
Any help would be appreciated
Kindest Regards |
|
| Back to top |
|
 |
RandomAccess Guest
|
Posted: Sat Apr 01, 2006 7:03 pm Post subject: Re: Need help with Bitmap Memory addressing |
|
|
I found the problem.
RowBytes was negative so I have to use ScanLine[Height - 1] to set my buffer
start pointer.
regards |
|
| Back to top |
|
 |
Jens Gruschel Guest
|
Posted: Sun Apr 02, 2006 11:03 am Post subject: Re: Need help with Bitmap Memory addressing |
|
|
| Quote: | RowBytes was negative so I have to use ScanLine[Height - 1] to set my buffer
start pointer.
|
Usually Windows stored DIBs bottom up, but top down is possible, too
(see BITMAPINFOHEADER and biHeight). So it's a good thing to use an
approach like this:
Origin := Bitmap.ScanLine[0];
Pitch := Integer(Bitmap.ScanLine[1]) - Integer(Origin);
Address := Pointer(Integer(Origin) + Y * Pitch + X * BytesPerPixel);
It works in bothg cases. Pitch is negative for bottom up bitmaps and
positive for top down bitmaps (TBitmap always uses bottom up AFAIK).
Accessing the whole bitmap with a single array is similar, but, well,
for 32 bit bitmaps it does work, because no padding bytes are used
between the single lines. The Graphics32 library uses the same approach
as you (except that it uses top down bitmaps IIRC), but keep in mind
that it won't work for (all) 24 bit bitmaps. IMO it's better to use the
formula above to initialize your array pointer for each line, and then
use it for that single line only. But I agree, using a single array for
the whole bitmap is easier.
--
Jens Gruschel
http://www.pegtop.net |
|
| Back to top |
|
 |
RandomAccess Guest
|
Posted: Tue Apr 04, 2006 5:03 am Post subject: Re: Need help with Bitmap Memory addressing |
|
|
Thanks Jens.
Much appreciated.
Kindest Regards |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|