Re: GDI full ??
- Posted by Derek Parnell <ddparnell at bigpond.com> Jul 10, 2001
- 478 views
This is a multi-part message in MIME format. ------=_NextPart_000_005A_01C1098C.F28728A0 boundary="----=_NextPart_001_005B_01C1098C.F28728A0" ------=_NextPart_001_005B_01C1098C.F28728A0 charset="Windows-1252" GlacierRenzo, you need to use the deleteResource() function to free up the bitmap = resources. Here is a short program to demonstrate what I mean: include win32lib.ew constant myWin =3D create( Window, "Bitmap View", 0, 0, 0, 0.99, 0.99, 0 ) constant myBitmap =3D create( Bitmap, "", myWin, 0, 0, 1000, 1000, 0 ) atom hBitmap hBitmap =3D 0 -- action to take when the window opens global procedure onOpen_myWin() if hBitmap !=3D 0 then -- Free up bitmap resources. deleteObject(hBitmap) end if =20 hBitmap =3D loadBitmapFromFile("C:\\windows\\webshots.bmp") setBitmap( myBitmap, hBitmap ) end procedure =20 -- tell Windows when to do the action onOpen[myWin] =3D routine_id( "onOpen_myWin" ) onClick[myWin] =3D onOpen[myWin] -- hand control over to Windows WinMain( myWin, Normal ) This loads a bitmap every time you click on the window. You can use a = system monitor to see that allocated memory is returned each time. -------- Cheers, Derek. ----- Original Message -----=20 From: renzo=20 To: EUforum=20 Sent: Monday, July 09, 2001 8:56 PM Subject: GDI full ?? Hi, I'm still having trouble with GDI memory,=20 since i use a graphics program to display a lot of BMP (1024*768,full = color), i keep having problems with GDI. After a couple of 100 times displaying a different picture Win32lib = gives an error saying it can not find the BMP anymore or it can not = display it. The BMP is still there in the same folder so it has to be Windows who = is out off GDI memory. My Question: when i load a bitmap into memory how can i reuse the same = memory for the next picture ? so i do not use other gdi memory for the next picture i switch to. I only need to show 1 big BMP at a time . I already relaese memory now, after switching, but that seems to leave = a memory leak.=20 (the program hangs after a week or so ; switched displaying 200 bmps a = day. after a reboot it works fine again) Kind Regards, Renzo Beggia from Belgium Email : renzo.beggia at vsk.be Or send an email To: EUforum-unsubscribe at topica.com This email was sent to: ddparnell at bigpond.com ------=_NextPart_001_005B_01C1098C.F28728A0 Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE>Glacier</TITLE> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Dwindows-1252"><BASE=20 href=3D"file://C:\Program Files\Common Files\Microsoft = Shared\Stationery\"> <STYLE>BODY { MARGIN-TOP: 20px; FONT-SIZE: 10pt; MARGIN-LEFT: 50px; COLOR: #006666; = FONT-FAMILY: Arial, Helvetica } </STYLE> <META content=3D"MSHTML 5.50.4611.1300" name=3DGENERATOR></HEAD> <BODY bgColor=3D#ffffff = background=3Dcid:005901c10939$20ca4fc0$9bd6fea9@xyzzy> <DIV><FONT color=3D#000000>Renzo,</FONT></DIV> <DIV><FONT color=3D#000000>you need to use the deleteResource() function = to free=20 up the bitmap resources. Here is a short program to demonstrate what I=20 mean:</FONT></DIV> <DIV><FONT color=3D#000000></FONT> </DIV> <DIV><FONT color=3D#000000></FONT> </DIV> <BLOCKQUOTE dir=3Dltr style=3D"MARGIN-RIGHT: 0px"> <DIV><FONT face=3D"Courier New" color=3D#000000 size=3D3>include=20 win32lib.ew<BR>constant myWin =3D<BR> create( = Window, "Bitmap=20 View", 0, 0, 0, 0.99, 0.99, 0 )</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D3></FONT> </DIV> <DIV><FONT face=3D"Courier New" color=3D#000000 size=3D3>constant = myBitmap =3D create(=20 Bitmap, "", myWin, 0, 0, 1000, 1000, 0 )</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D3></FONT> </DIV> <DIV><FONT face=3D"Courier New" color=3D#000000 size=3D3>atom = hBitmap<BR>hBitmap =3D=20 0</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D3></FONT> </DIV> <DIV><FONT face=3D"Courier New" color=3D#000000 size=3D3>-- action to = take when the=20 window opens<BR>global procedure onOpen_myWin()</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D3></FONT> </DIV><FONT = color=3D#000000> <DIV><BR><FONT face=3D"Courier New" size=3D3> if = hBitmap !=3D 0=20 then<BR> -- Free up bitmap=20 resources.<BR> =20 deleteObject(hBitmap)<BR> end=20 = if<BR> = <BR> hBitmap =3D=20 loadBitmapFromFile("C:\\windows\\webshots.bmp")</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D3></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D3> setBitmap( = myBitmap,=20 hBitmap )<BR>end procedure<BR> <BR>-- tell Windows when to = do the=20 action<BR>onOpen[myWin] =3D routine_id( "onOpen_myWin" = )<BR>onClick[myWin] =3D=20 onOpen[myWin]</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D3></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D3>-- hand control over to=20 Windows<BR>WinMain( myWin, Normal = )<BR></FONT></FONT></DIV></BLOCKQUOTE> <DIV><FONT color=3D#000000>This loads a bitmap every time you click on = the window.=20 You can use a system monitor to see that allocated memory is returned = each=20 time.</FONT></DIV> <DIV><FONT color=3D#000000></FONT> </DIV> <DIV><FONT color=3D#000000>--------</FONT></DIV> <DIV><FONT color=3D#000000>Cheers,</FONT></DIV> <DIV><FONT color=3D#000000>Derek.</FONT></DIV> <DIV>----- Original Message ----- </DIV> <BLOCKQUOTE dir=3Dltr=20 style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; = BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"> <DIV=20 style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: = black"><B>From:</B>=20 <A title=3Drenzo.beggia at vsk.be = href=3D"mailto:renzo.beggia at vsk.be">renzo</A>=20 </DIV> <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A = title=3DEUforum at topica.com=20 href=3D"mailto:EUforum at topica.com">EUforum</A> </DIV> <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Monday, July 09, 2001 = 8:56 PM</DIV> <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> GDI full ??</DIV> <A = <DIV>since i use a graphics program to display a lot of BMP = (1024*768,full color), i keep having problems with GDI.</DIV> <DIV> </DIV> <DIV>After a couple of 100 times displaying a different picture = Win32lib gives=20 an error saying it can not find the BMP anymore or it can not display=20 it.</DIV> <DIV> </DIV> <DIV>The BMP is still there in the same folder so it has to be Windows = who is=20 out off GDI memory.</DIV> <DIV> </DIV> <DIV>My Question: when i load a bitmap into memory how can i reuse the = same=20 memory for the next picture ?</DIV> <DIV>so i do not use other gdi memory for the next picture i switch = to.</DIV> <DIV> </DIV> <DIV>I only need to show 1 big BMP at a time .</DIV> <DIV>I already relaese memory now, after switching, but that seems to = leave a=20 memory leak. </DIV> <DIV>(the program hangs after a week or so ; switched displaying 200 = bmps a=20 day. after a reboot it works fine again)</DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV>Kind Regards,</DIV> <DIV> </DIV> <DIV>Renzo Beggia from Belgium<BR>Email : <A=20 href=3D"mailto:renzo.beggia at vsk.be">renzo.beggia at vsk.be</A></DIV> = <P> </P><PRE>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= <A = href=3D"http://topica.com/u/?b1dd66.${encoded_sub_id}">http://topica.com/= u/?b1dd66.b2mL5y</A> Or send an email To: EUforum-unsubscribe at topica.com This email was sent to: ddparnell at bigpond.com <A = ------=_NextPart_001_005B_01C1098C.F28728A0-- ------=_NextPart_000_005A_01C1098C.F28728A0 Content-Type: image/jpeg; name="Glacier Bkgrd.jpg" Content-Transfer-Encoding: base64