[Qt-interest] QImage bytesPerLine != width()*depth()/8 Why?
Paul Miller
paul at fxtech.com
Wed Sep 21 03:33:02 CEST 2011
On 9/20/2011 6:39 PM, MARTIN Pierre wrote:
> Thanks Rohan for your answer,
>
>> QImage enforces that the address of each line starts on a multiple of 4
>> bytes. Therefore, 1377 was rounded up to 1380 in your case.
> Well, i understand for 32bpp ARGB images. But *why is it so for 8bpp
> images*? This defeats ease of communication with other APIs which expect
> "inline" scan-lines.
> Is there a way to force QImage to have it's Bpl = width when depth = ,
> without copying it manually to another memory area?
Probably not. 4 (or 16) byte alignment is used so fancy SSE instructions
can be used for extra performance. If your library requires the image to
be w*h in size you'll probably have to copy the image data.
But in over 20 years of image processing I've never seen any library
that works with images that doesn't support arbitrary row-bytes. Maybe
you can go to the API vendor and ask them to extend it? It doesn't seem
very well designed as it is.
More information about the Qt-interest-old
mailing list