Re: [GD-DEVEL] [proposal] Attach DIB section buffer to gdImage
[email protected] ("Pierre Joye")
| Newsgroups | php.gd.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Markus, Mateusz! On Feb 13, 2008 7:47 AM, Markus Fleck-Graffe <[email protected]> wrote: > Pierre schrieb: > > I'm finishing the initial support of the new formats. The two most > > important additions for you and other users are the true 8bit per > > channel (alpha) and the contiguous buffer instead of per row > > allocation. It will let you use a DIB/BMP (or any compatible buffer) > > directly without any extra allocations or loop. It will require a lof > > tests and work to get stable enough for 2.1.x :) > > For what it's worth, there is a documentation of the Windows > DIB/BMP in-memory format at the following URL: > > http://support.microsoft.com/?scid=kb%3Ben-us%3B81498&x=12&y=14 > > It appears that some alignment issues must be observed in order > to be able to use plain RGB-style buffers directly on Microsoft Windows: > > "Every scanline is DWORD-aligned. The scanline is buffered to alignment; > the buffering is not necessarily 0." (On Windows, a DWORD equals 4 bytes.) > > But things get even worse: > - "Red, green, and blue bytes are in reverse order (red swaps position > with blue) from the Windows convention." > - "The scanlines are stored upside down" It is actually (according to Petzold too) platform specific, GD is also platform specific. I don't have non intel (or compatible) windows to test the correctness of this behavior but it seems to work well on my boxes (vista, xp, xp64). > (The article blames the latter two conventions on some alleged OS/2 > Presentation Manager compatibility.) > > So unless the pending (new) GD in-memory data format will offer > a possibility for "DWORD 4-byte alignment padding" upon creation of > a new image buffer, exporting a GD image to a Microsoft Windows DIB > will require copying of the whole image (in addition to the additional > RGB/BGR and upside-down hassle). I may be wrong but the memory buffer is actually always aligned. It is done by the compiler directly and extra bytes will be inserted if necessary. You can try to run the windows.c example in CVS (libgd/example), that's what I use to test on various windows. I will read again the DIB and windows API docs, I'll not be surprised if I see other annoying issues :) Thanks for your feedbacks and comments! Grüße, -- Pierre http://blog.thepimp.net | http://www.libgd.org