CreateDIBSection help

This is a discussion on CreateDIBSection help within the Windows Programming forums, part of the Platform Specific Boards category; Code: HDC pDC; HBITMAP old; HBITMAP ourBitmap; int* buffer; void RenderEffect( int iTick, int* pBuffer ) { int i, j, ...

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    89

    CreateDIBSection help

    Code:
    HDC pDC;
    HBITMAP old;
    HBITMAP ourBitmap;
    int* buffer;
    
    void RenderEffect( int iTick, int* pBuffer )
    {
        int i, j, k;
        iTick /= 4;
    
        for( k = 0, i = 0; i < 200; i++ )
        {
            for( j = 0; j < 320; j++, k++ )
            {
                *( pBuffer + k ) = RGB( SINTAB[( i + iTick ) & 0xff],
                                        SINTAB[( j - iTick ) & 0xff],
                                        SINTAB[( SINTAB[iTick & 0xff] + ( k << 6 ) ) & 0xff] );
    
            }
        }
    }
    
    void Render( HDC hDC )
    {
        RenderEffect( GetTickCount(), buffer );
        BitBlt( hDC, 0, 0, 320, 200, pDC, 0, 0, SRCCOPY );
    }
    
    void DeInitFramebuffer( void )
    {
        SelectObject( pDC, old );
        DeleteDC( pDC );
        DeleteObject( ourBitmap );
    }
    
    void InitFramebuffer( void )
    {
        HDC hDC;
        BITMAPINFO bitInfo;
    
        bitInfo.bmiHeader.biSize = sizeof( BITMAPINFOHEADER );
        bitInfo.bmiHeader.biWidth = 300;
        bitInfo.bmiHeader.biHeight = -200;
        bitInfo.bmiHeader.biPlanes = 1;
        bitInfo.bmiHeader.biBitCount = 32;
        bitInfo.bmiHeader.biCompression = BI_RGB;
        bitInfo.bmiHeader.biSizeImage = 0;
        bitInfo.bmiHeader.biClrUsed = 256;
        bitInfo.bmiHeader.biClrImportant = 256;
    
        ourBitmap = CreateDIBSection( hDC, &bitInfo, DIB_RGB_COLORS, &buffer, 0, 0 );
        pDC = CreateCompatibleDC( NULL );
        old = SelectObject( pDC, ourBitmap );
        DeleteDC( hDC );
    }
    the errors I get are:

    main.cpp||In function `int WinMain(HINSTANCE__*, HINSTANCE__*, CHAR*, int)':|
    main.cpp|15|warning: converting to `char' from `double'|
    main.cpp||In function `void InitFramebuffer()':|
    main.cpp|104|error: invalid conversion from `int**' to `void**'|
    main.cpp|104|error: initializing argument 4 of `HBITMAP__* CreateDIBSection(HDC__*, const BITMAPINFO*, UINT, void**, void*, DWORD)'|
    main.cpp|106|error: invalid conversion from `void*' to `HBITMAP__*'|

    ||=== Build finished: 3 errors, 1 warnings ===|

    I am trying to understand why those errors are actually errors. You should be able to cast anytype of ** to a void** right?

    BTW why are the code tags not working? What did I do wrong there?
    Last edited by eaane74; 10-27-2009 at 04:27 PM.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    The close code tag looks like [/code]. In C++ there aren't really any default pointer conversions -- if you want to convert an int** to a void** you have to specify that with a cast.

  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    89
    I'm passing a int* by reference, so I am not sure on the syntax.
    Code:
    ( void** )&buffer

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    That would cast the address of buffer to void**.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. workarround with CreateDIBSection
    By rommi in forum Windows Programming
    Replies: 0
    Last Post: 02-15-2009, 02:57 PM
  2. CreateDIBSection() returning NULL
    By arjunajay in forum Windows Programming
    Replies: 5
    Last Post: 07-26-2006, 10:54 AM
  3. MapViewOfFile and CreateDIBSection problem with bitmaps
    By LuckY in forum Windows Programming
    Replies: 2
    Last Post: 08-18-2004, 09:37 AM
  4. Loading bitmaps with createfile() +CreateDIBSection
    By Stevo in forum Windows Programming
    Replies: 7
    Last Post: 05-13-2004, 10:22 PM

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