August 12th, 2003, 07:14 PM
C++ (Load then paint Image data )
What is the simplest way in c++ to load image data in RGBA format and "paint" it on a Windows Device Context . I know you would have to use CImage in some way for this. But how?
August 13th, 2003, 03:42 AM
You might have better luck asking a windows programming question on a windows programming forum.
August 13th, 2003, 05:18 AM
This works only with bitmaps (as windows uses bitmaps unless you go to GDI++ or a third party lib)
It is a NOT the best way (by a long way) and will NOT produce speedy flicker free updates.
you should also use a frame buffer but...........
This is some MFC C++, let me know if you prefer WIN32 C
//load image from file to member var ( a HBITMAP )
sprintf(m_sImage, ".\\Images\\AnImage.bmp" ); // set the images full path from file
m_hImage = (HBITMAP) LoadImage( hInstance, m_sImage, IMAGE_BITMAP ,0 ,0 ,LR_LOADFROMFILE );
// find size of image
GetObject( m_hImage ,sizeof( BITMAP ), &BMP);
CPaintDC dc(this); // device context for painting
//we need something to draw from
//create a compatible DC and select our image into it
DC.CreateCompatibleDC( &dc );// create DC compat to screen
HBITMAP hOld = (HBITMAP) DC.SelectObject( m_hImage );// catch the current bitmap
//draw to the screen DC
dc.BitBlt( 0, 0, BMP.bmWidth, BMP.bmHeight, &DC ,0 ,0 ,SRCCOPY);
DC.SelectObject( hOld);// put the old back
DC.DeleteDC(); // delete what we created
The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.
August 13th, 2003, 10:19 AM
I have access to third party software. Will this ease the task. If so can you show me how to use either the W2K gdiplus AlphaBlend function and/or the MFC/ATL CImage object. Thanks!