C Board  

Go Back   C Board > Platform Specific Boards > Windows Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 10-27-2009, 03:07 PM   #1
Registered User
 
Join Date: Jan 2007
Posts: 87
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 03:27 PM.
eaane74 is offline   Reply With Quote
Old 10-27-2009, 03:25 PM   #2
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,740
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.
tabstop is offline   Reply With Quote
Old 10-27-2009, 03:34 PM   #3
Registered User
 
Join Date: Jan 2007
Posts: 87
I'm passing a int* by reference, so I am not sure on the syntax.
Code:
( void** )&buffer
eaane74 is offline   Reply With Quote
Old 10-27-2009, 04:57 PM   #4
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,740
That would cast the address of buffer to void**.
tabstop is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
workarround with CreateDIBSection rommi Windows Programming 0 02-15-2009 02:57 PM
CreateDIBSection() returning NULL arjunajay Windows Programming 5 07-26-2006 09:54 AM
MapViewOfFile and CreateDIBSection problem with bitmaps LuckY Windows Programming 2 08-18-2004 08:37 AM
Loading bitmaps with createfile() +CreateDIBSection Stevo Windows Programming 7 05-13-2004 09:22 PM


All times are GMT -6. The time now is 01:05 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

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