VFP handles some images differently with GDIPlus
Visual Foxpro 9 uses GDIPlus to handle certain kinds of image files, such as JPG, GIF. Because the ability to decode image formats is now centralized in the operating system, VFP can take advantage of OS updates to file formats as well as other formats like WMF.
Sometimes, GDIPlus is just used to read the image files and the rendering is done by VFP. For some formats (such as animated GIFs or images with alpha blend (transparency)), GDIPlus is used to draw the image as well. Because VFP caches some images as “resources”, interesting problems can arise.
The code below creates a file called temp.prg that creates a form with an image control showing an animated GIF It then builds an APP file that embeds the GIF file directly internally and runs the code. If you run the program, you see the animated GIF on a form. Close the form and try to run the program again, and VFP hangs in an infinite loop trying to close a file handle for the GIF file that’s inside the APP.
The GIF is a cached image resource that GDIPlus still holds. Simple fix: it can be released via the CLEAR RESOURCE line.
(You can use this animated GIF as a sample )
#define TESTGIF "d:\monster.gif"
TEXT TO ctemp noshow && create a string with a few lines of code
PUBLIC x as Form
x=CREATEOBJECT("form")
x.Visible=1
x.addobject("img","image") && add an image control and call it "img"
x.img.picture=TESTGIF
x.img.visible=1
ENDTEXT
STRTOFILE(ctemp,"temp.prg") && save as a file on disk
BUILD PROJECT temp FROM temp && build a project
MODIFY PROJECT temp nowait && add the GIF to the project so it's embedded inside the target APP, EXE ,or DLL
_vfp.ActiveProject.Files.Add(TESTGIF)
_vfp.ActiveProject.Close
*CLEAR RESOURCES TESTGIF && this line will fix the problem
BUILD APP temp FROM temp && build the APP (or exe)
DO temp && do the APP (or exe)
78397
Comments
Anonymous
July 18, 2005
The comment has been removedAnonymous
July 24, 2005
 
I received a comment on my blog VFP handles some images differently with GDIPlus
Here's another...Anonymous
September 23, 2005
I've had problems in VFP 9 with it hanging on a build. Could this problem be caused by what you mention here? The program has no animated GIFs, but does have GIFs and other images built into the EXE. Thanks.Anonymous
March 16, 2007
thoughts from a professional developer I do not agree. Go to http://www.jobznews.info/eldest_Poland/astral_West%20Poland/yack_Poznan_1.htmlAnonymous
March 19, 2007
thoughts from a professional developer I do not agree. Go to http://www.greatworkz.info/welt_Portugal/chyme_Lisbon%20Coast/pediatrics_Lisboa_1.htmlAnonymous
March 27, 2007
thoughts from a professional developer I do not agree. Go to http://www.intrades.info/owl_Spain/wham_Catalu%C3%83%C2%B1a/irreparably_Barcelona_1.htmlAnonymous
March 28, 2007
thoughts from a professional developer I do not agree. Go to http://www.jobzlife.info/univalve_Italy/abbe_Lazio/surmullet_Rome_1.html