VoyForums

VoyUser Login optional ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time | Archives: 1234567[8]910 ]


[ Next Thread | Previous Thread | Next Message | Previous Message ]

Date Posted: 00:39:31 06/04/01 Mon
Author: Vivek Borkar
Subject: BMP file display

Hi,

Please see the following peice of code, I'm calling this function in timer routine, to toggle between the Images every 55 mSec. This works fine initially, but after few times of toggling, The screen becomes black and I got a error message, "Out of virtual memory".

My aim is to display 2 images simultaniously reading from a file.
please help me out.

code:
_____________________________

void CTry2Dlg::DisplayBMP()
{

CString temp;
BITMAP bit,bit1;
int x,y;
//CPaintDC dc(this);
CClientDC dc(this);
HDC hdc,temp_hdc,temp_hdc1;
hdc = dc.GetSafeHdc();

if(toggle)
{

temp_hdc = CreateCompatibleDC(hdc);

m_Hbitmap = (HBITMAP)LoadImage(AfxGetInstanceHandle(), "D:\\old_D\\vib\\bmpconvertion\\102.bmp", IMAGE_BITMAP, 684, 512, LR_LOADFROMFILE/*|LR_CREATEDIBSECTION*/);
m_HbitmapNew = (HBITMAP)SelectObject(temp_hdc,m_Hbitmap);
GetObject(m_Hbitmap,sizeof(BITMAP),&bit);
x = bit.bmWidth;
y = bit.bmHeight;

BitBlt(hdc,0,0,x,y,temp_hdc,0,0,SRCCOPY);
SelectObject(temp_hdc,m_HbitmapNew);

DeleteObject(m_HbitmapNew);
DeleteDC(temp_hdc);
toggle = 0;
}
else
{
temp_hdc1 = CreateCompatibleDC(hdc);


m_Hbitmap1 = (HBITMAP)LoadImage(AfxGetInstanceHandle(), "D:\\old_D\\vib\\bmpconvertion\\103.bmp", IMAGE_BITMAP, 684, 512, LR_LOADFROMFILE/*|LR_CREATEDIBSECTION*/);
m_HbitmapNew1 = (HBITMAP)SelectObject(temp_hdc1,m_Hbitmap1);
GetObject(m_Hbitmap1,sizeof(BITMAP),&bit1);
x = bit1.bmWidth;
y = bit1.bmHeight;

BitBlt(hdc,0,0,x,y,temp_hdc1,0,0,SRCCOPY);
SelectObject(temp_hdc1,m_HbitmapNew1);

DeleteObject(m_HbitmapNew1);
DeleteDC(temp_hdc1);

toggle = 1;

}

}

Thanks,

Vivek

[ Next Thread | Previous Thread | Next Message | Previous Message ]

[ Contact Forum Admin ]


Forum timezone: GMT-5
VF Version: 2.94, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2008 Voyager Info-Systems. All Rights Reserved.