Thread: The pointer to a pointer in CreateDIBSection

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    596

    The pointer to a pointer in CreateDIBSection

    Petzold shows using it like this:

    BYTE *pBits;
    hBitmap = CreateDIBSection( ... &pBits ...);

    That will not compile with Pelles.I have to use a VOID type as it is prototyped in the msdn library:

    VOID *pBits;
    hBitmap = CreateDIBSection( ... &pBits ...);

    I assume the msdn type delaration is correct.
    If so, is this also correct, if I want to write 4 bytes using that pointer:

    VOID *pBits;
    DWORD *pixel;

    hBitmap = CreateDIBSection( ... &pBits ...);

    pixel = (DWORD*) pbits;

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Yes, that looks OK.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    596
    Thanks

    It was taking about 2 seconds to set 1000 x 750 (750,000) points in a bitmap using SetPixel;
    With the DIBSection, writing in the color values directly, it's virtually instantaneous. No noticeable
    delay.

    Very easy to use also, with 24 or 32 bit colors.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 10-30-2009, 04:41 PM
  2. Replies: 9
    Last Post: 06-13-2009, 02:31 AM
  3. Replies: 1
    Last Post: 03-24-2008, 10:16 AM
  4. Replies: 4
    Last Post: 08-27-2007, 11:51 PM
  5. Replies: 2
    Last Post: 10-12-2002, 07:44 PM