[lazarus] Bitmap transparency?
Mattias Gaertner
nc-gaertnma at netcologne.de
Wed Nov 12 14:37:08 EST 2003
On Wed, 12 Nov 2003 20:31:08 +0100
Micha Nelissen <M.Nelissen at student.tue.nl> wrote:
>[...]
> > Ok. So, under win32 it seems, it is up to the user to keep book of the
> > format of a DC/bitmap. But this data is win32 specific, so the LCL user
> > can't do it. It must be done, by the win32 intf. Right?
>
> Let me first say: the color format I mean is the RRGGBBAA and how bits
> each take.
>
> Yes. But the winapi can convert between color formats automatically. You
> give the win32 interface a color format, and it can pass it on to the
> winapi for processing.
Yes. But every conversion reduces the quality, so we should try to find the
current format.
> >>3) there is no function to retrieve the color format of a device. One
> >>can only guess at it, based on BITMAPINFO structure help. That's because
> >
> >>the winapi support converting the color formats on the fly. For example,
> >
> >>using CreateDIBitmap, you specify the color format your source bitmap is
> >
> >>in, and the winapi will convert it to the color format of the target
> >>device. It seems logical that one would be able to retrieve the color
> >>format of the device for fast rendering and stuff, but it just seems
> >>impossible.
> >
> >
> > Hardly believable.
> > Can this BITMAPINFO only retrieved from bitmaps or can you create a
> > bitmap fom any device and get a BTMAPINFO? And with this, get the color
> > format from any DC?
>
> The BITMAPINFO is contained with a DIBSECTION. The DIBSECTION can only
> be retrieved for device independant bitmaps, that means, bitmaps created
> by CreateDIBSection. No other function returns a BITMAPINFO structure.
>
> The BITMAP structure can always be retrieved from any bitmap. But it
> doesn't contain the information to fill in {red,blue,green}{shift,prec}.
AFAIK the INFOHEADER does. See for example
http://astronomy.swin.edu.au/~pbourke/dataformats/bmp/.
> Creating a DIB section isn't of much use, if you ask me, because that's
> already what the rawimage is.
>
> >>I think that's the reason why in delphi there is a pfDevice
> >>for TPixelFormat.
> >>
> >>Any tips? Shall I return a default color format in the raw image?
> >
> >
> > Yes. I guess, at least the screen resolution can be retrieved, can't it?
>
> I am able to get the color depth and bits per pixel used, eg. 16, 24, 32
> bits.
I guess, win32 also defines, what bits are the red, green and blue?
Mattias
More information about the Lazarus
mailing list