Loading...

Files arent being released properly

Support for GdPicture Light Imaging Toolkit and GdPicture Pro Imaging ActiveX/SDK.

Files arent being released properly

Postby Tod » Wed Nov 05, 2008 10:37 pm

A somewhat critical bug I have found with the way Imaging handles files. This is easily replicatable using the Delphi image viewer sample provided with the component install.

Open a JPG file for viewing with the sample application. With the file open in the viewer, navigate to the folder where the file exists and delete the file. This operation works as it should. The file is deleted.

Open a BMP file for viewing with the sample application. With the file open, navigate to the folder where it exists and try to delete the file. This operation will fail every time saying the file is in use. You can delete the file only if you CloseImage. However, this is not desired.

My guess is the file handle isnt being released properly when opening BMP files.
Tod
 
Posts: 3
Joined: Wed Nov 05, 2008 9:36 pm

Re: Files arent being released properly

Postby Loïc » Thu Nov 06, 2008 2:44 pm

HI Tod,

This is not a bug. For some image formats GdViewer needs to keep the source file locked.
If you want to be able to delete the opened file you need to turn the ImageForceTemporaryMode property to true.

Best regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4430
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: Files arent being released properly

Postby Tod » Thu Nov 06, 2008 4:07 pm

Ahhh ok, thank you very much :D
Tod
 
Posts: 3
Joined: Wed Nov 05, 2008 9:36 pm

Re: Files arent being released properly

Postby Tod » Thu Nov 06, 2008 5:04 pm

Hi Loïc,

After playing around with it, I see that it does work for gdPicture, however does not work for Imaging. (which is my real issue). Is there a similar property that can force Imaging to do the same?

My application displays a list of scanned images to the end user. This list is displayed using an embeded shell control so the user has access to all normal context menu items if they right click on the image. This allows them to select an image to view, and apply corrections like rotation, skew, contrast, etc. If I was just using the gdViewer component, then they wouldn't be able to apply corrections to the images, so I must open it with an Imaging object. Many times they have images they just with to delete. With the Imaging control holding a lock on the file, they are unable to do so.

I realize one possible solution would be to create copys of the image they selected for correction, (Possibly using the CreateClonedImageI function?) but was wondering if Imaging has a similar property to that of gdPicture.
Tod
 
Posts: 3
Joined: Wed Nov 05, 2008 9:36 pm

Re: Files arent being released properly

Postby Loïc » Thu Nov 06, 2008 8:42 pm

Hi Tod,

I see 3 solutions:

1- Open your image with the GdViewer & set it to the Imaging control like that:

Code: Select all
Imaging1.SetNativeImage(GdViewer1.GetNativeImage())


or

2 - Before opening your file, create a temporary copy.

ro

3 - Use the CreateClonedImageI() method to get a bitmap stored in memory.

Best regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4430
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: Files arent being released properly

Postby Chico » Tue Jul 13, 2010 5:05 pm

Hi there,

I've also got big problems with locked source files!
My application includes gdPictureViewer and gdImaging components.
I open a Copy of the original BMP, TIF or JPG file with the following code
(where fso is a scripting.filesystemobject, gdiDokImage is a gdImaging-Component
and gdpDokImage is a gdViewer-Component):

Code: Select all
    tmpFileName_Edit = tmpPath + "\~" + realFileName
    fso.copyFile(realFileName, tmpFileName_Edit, True)
    gdiDokImage.CreateImageFromFile (tmpFileName_Edit)
    gdpDokImage.SetNativeImage (gdiDokImage.GetNativeImage)

then I rotate or scale it, e.g.:

    gdpDokImage.Rotate90

and - last not least - I want to save the changes:

    nCloneImage = gdiDokImage.CreateClonedImageI(gdiDokImage.GetNativeImage)
    Ergebnis = gdiDokImage.CloseNativeImage
    Call gdiDokImage.SetNativeImage(nCloneImage)
    Select Case fileType
        Case "JPG", "jpg"
            Call fso.DeleteFile(realFileName, True)
            Call gdiDokImage.SaveAsJPEG(realFileName, curJPGQuality)
        Case "BMP", "bmp"
            Call fso.DeleteFile(realFileName, True)
            Call gdiDokImage.SaveAsBmp(realFileName)
        Case "TIF", "tif"
            Call fso.DeleteFile(realFileName, True)
            Call gdiDokImage.SaveAsTIFF(realFileName, CompressionLZW)
    End Select
   
then even I ill the content of the gdPictures with

    gdiDokImage.CloseImage(gdiDokImage.GetNativeImage)
    gdpDokImage.Clear


I only can run this code one time in case of TIF or BMP-Files, with JPG it works several times!
When i try a second saving operation the "fso.DeleteFile"-command raises an Err code 70 (Access denied)

I tried out everything I could find in this forum to solve the problem, but without success....

Why doesn't the gdPicture.ocx offer a simple SAVE-command???
It seems to be very complicated to do a saving operations, without any sense to me!! Because I WANT to
manipulate the original File.

So, I would be very glad, if anybody could help me. It's quite urgent!!

Thanks for any suggestions!!
Tobias
Chico
 
Posts: 5
Joined: Fri Nov 13, 2009 11:26 am

Re: Files arent being released properly

Postby Loïc » Wed Jul 14, 2010 9:07 am

Hi Tobias,

Please give me a simple procedure which I can run as is for investigation. I hate fso & I never understood how to use it correctly.
So if you can give a function with all object declaration I will be able to help in no-time.

Kind regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4430
Joined: Tue Oct 17, 2006 10:48 pm
Location: France


Return to GdPicture [Pro] ActiveX

Who is online

Users browsing this forum: No registered users and 2 guests

cron