Click to See Complete Forum and Search --> : How to display a bitmap?


Ava
September 24th, 2004, 12:03 AM
hey there..
does anyone know how to display a bitmap picture in the view class of the project..
the bitmap picture must be in red... with the red values of the picture already extracted and stored in an array called REDARRAY.
basically it means displaying a picture in which the values are all set by us..
dun think can use functions from the CBitmap class..
need to use the CGdiObject class..
By the way..
i am using Visual C++ v.6.0 and under AppWizard.exe
will be grateful for your help..

DRZ
September 24th, 2004, 01:25 AM
//Member Variables
BOOL m_bFlag;
CBitmap m_bmpScreen;


//Initialize in c'tor
m_bFlag = FALSE;

Add a bitmap in resource - IDB_BITMAP_MAINSCREEN


void CMyTestView::OnPaint()
{
CPaintDC dc(this); // device context for painting

// TODO: Add your message handler code here
CRect rcScreen;
GetClientRect(&rcScreen);
CDC cdc;

if(FALSE == m_bFlag)
{
m_bmpScreen.LoadBitmap(IDB_BITMAP_MAINSCREEN);
m_bFlag = TRUE;
}
if(m_bmpScreen.m_hObject)
{
cdc.CreateCompatibleDC(&dc);
cdc.SelectObject(&m_bmpScreen);

BITMAP bitmap;
m_bmpScreen.GetBitmap(&bitmap);

dc.StretchBlt(rcScreen.left, rcScreen.top, rcScreen.Width(), rcScreen.Height(),
&cdc, 0, 0, bitmap.bmWidth, bitmap.bmHeight, SRCCOPY);
}
}