VoyForums
[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):

Login ] [ 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: 3.00b, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.