Re: [GD-DEVEL] [proposal] Attach DIB section buffer to gdImage

[email protected] (Markus Fleck-Graffe)
Newsgroups php.gd.devel
Message-ID <[email protected]>
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"

(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).

Yours,
Markus.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.