The pointer to a pointer in CreateDIBSection

This is a discussion on The pointer to a pointer in CreateDIBSection within the Windows Programming forums, part of the Platform Specific Boards category; Petzold shows using it like this: BYTE *pBits; hBitmap = CreateDIBSection( ... &pBits ...); That will not compile with Pelles.I ...

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

    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,485
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    406
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21