neal$2006275 neal 03/02/2007 :: 19:21
Registered
| | Hello Loic,
I have run into what is probably a simple problem. I have an application that allows my users to browse through the faxes we have received on our fax server. The faxes are stored as TIF files. I want the user to be able to rotate and save the images. I am working in Visual FoxPro 9
Here's what I have right now.
In my Form's init I initialize an oGdPicture object. -------------------------------------- PUBLIC oGdPicture oGdPicture = CREATEOBJECT("gdpicturepro.cgdpicture") -------------------------------------- There is a oGdViewer control object in the form as well. when the user selects a fax from the list, the viewer is updated to show the correct fax: -------------------------------------- oGdPicture.LoadFromFile(vPath) thisform.ogdViewer.DisplayFromImageRef(oGdPicture.GetNativeImage()) thisform.ogdViewer.SetZoomFit --------------------------------------
I use the following code to rotate / save the image: -------------------------------------- LPARAMETERS sInputTifPath, sOutputTifPath, nRotation oGdPicture3 = CREATEOBJECT("gdpicturepro.cgdpicture") oGdPicture4 = CREATEOBJECT("gdpicturepro.cgdpicture") nStat = oGdPicture3.LoadFromFile(sInputTifPath) If nStat = 0 Then nInputTifHandle = oGdPicture3.GetNativeImage For nCpt = 1 To oGdPicture3.TiffGetPageCount oGdPicture3.SetNativeImage (0) oGdPicture3.CloneImage (nInputTifHandle) oGdPicture3.TiffSelectPage (nCpt) oGdPicture3.Rotate (nRotation) If nCpt = 1 Then nOutputTifHandle = oGdPicture3.GetNativeImage oGdPicture4.SetNativeImage (nOutputTifHandle) nStat = oGdPicture4.TiffSaveAsNativeMultiPage(sOutputTifPath, 2) Else If nStat = 0 Then nStat = oGdPicture4.TiffAddToNativeMultipage(oGdPicture3.GetNativeImage) oGdPicture3.CloseImage(oGdPicture3.GetNativeImage) EndIf EndIf Next nCpt oGdPicture3.CloseImage(nInputTifHandle) oGdPicture3.CloseImage(nOutputTifHandle) ENDIF --------------------------------------
This works fine, saving to a new file name, but it will not let me overwrite the existing file (which makes sense since I am reading and saving in the for loop). So my idea here is to save to a temp file and then copy the temp file, delete the original, copy the temp to the original file name, and then delete the temp file.
My problem occurs, because I cannot delete or overwrite the original file. I receive an access denied error. (Actually it works occasionally, but not more than once for some reason). The problem seems to be that the original file is still open and so cannot be deleted / overwritten.
I have tried using the closeImage method, but the file is still in use after the closeImage method.
My current code trying to close all references to the original file is here: ------------------------------- oGdPicture3.loadFromFile("blank.bmp") RELEASE oGdPicture3 oGdPicture4.loadFromFile("blank.bmp") RELEASE oGdPicture4 oGdPicture.closeImage(oGdPicture.GetNativeImage) oGdPicture.loadFromFile("blank.bmp") -------------------------------- I thought that by opening a different image it would close out the image that was in use. This does not appear to work though.
I was trying to figure out if the DeletePicture method would work, but was unable to figure out how to reference it.
Do you have any thoughts on what I am missing here?
Thanks,
Neal. | |