Basic Bitmap Questions
Posted on 1998-03-06
I'm trying to learn how to program bitmaps.
using Petzold and VC5 documentation.
I am having lots of trouble understanding things. I hope someone can help.
Here are a few of the questions I have:
1) The HBITMAP type.
Is it a handle to a DIBitmap, a GDI bitmap, neither, both?
Does it create, in memory, a DIBitmap or a GDI bitmap?
Petzold hints that it's a DIB, but on p.201 he uses it with
CreatePatternBrush() rather than CreateDIBPatternBrush().
Also, the M$ doc says that the bitmap returned, must be
deleted with DeleteObject(), which is only true for GDI objects.
If it's a GDI bitmap, then how so you load a bitmap resource
into what Petzold calls "Packed DIB Format"?
Petzold says this gets bits from a DIB, and to use GetBitmapBits()
for getting bits from a GDI bitmap.
The M$ doc says GetBitmapBits() is obsolete, use GetDIBits().
Can you get bits from a GDI bitmap using a funtion for a DIBitmap?
More confusing is that GetDIBits() uses HBITMAP for its bitmap,
while functions like CreateDIBPatternBrush(), which handle DIBs,
uses HGLOBAL for their bitmap.
4) Petzold says "Packed DIB Format" (and I quote) "contains
everything in the DIB file except the BITMAPFILEHEADER structure".
But the M$ doc says, in its doc for CreateDIBPatternBrush(),
Identifies a global memory object containing a packed DIB,
which consists of a BITMAPINFO structure immediately followed
by an array of bytes defining the pixels of the bitmap. "
which leaves out the color table and BITMAPV4HEADER.
5) Some M$ functions refer to DIBSection. What's that?
It looks a lot like what Petzold calls a "Packed DIB Format"
I have more questions, but the answers to these might resolve them.