Page 1 of 1

oPicture:SaveImage does not work

Posted: Mon Sep 10, 2007 10:50 am
by Willy
Here is a sample of the code I used.

It generated only an empty file of 0 bytes.

Someone an idea of what I am doing wrong.

Code: Select all

Static Function LoadJpg(oPicture,cId)
cId := Trim(cId) + ".JPG"
oPicture:LoadFromClipboard()

oPicture:Refresh()

Return Nil

Static Function SaveJpg(oPicture,cId)
cId := Trim(cId)

oPicture:SaveImage(cId,2,25)
Return Nil
Thanks
Willy

Re: oPicture:SaveImage does not work

Posted: Mon Sep 10, 2007 11:27 am
by Enrico Maria Giordano
Use this modified SaveImage() method:

Code: Select all

METHOD SaveImage( cFile, nFormat, nQuality ) CLASS TImage

   //   0 -> Bmp
   //   2 -> Jpg
   //  13 -> Png

   local hDib := DibFromBitmap( ::hBitmap )
   local cTempFile := cTempFile()
   local lSaved

   DibWrite( cTempFile, hDib )

   GloBalFree( hDib )

   lSaved = FISaveImg( cTempFile, cFile, nFormat, nQuality )

   FErase( cTempFile )

return lSaved
EMG

Posted: Mon Sep 10, 2007 11:41 am
by Willy
Hello,

I was aleady using this version of this method.

However I have copied it. The result is the same. There is a JPG file created from 0 bytes.

I use the freeimage.dll from 4SEP2005 19h01 from 1032 Kb.

This is the one that is delivered with the latest FWH

Thanks,

Willy

Posted: Mon Sep 10, 2007 1:05 pm
by Willy
I think I found an error in the tImage class.

In the header the method SaveImage does not mention the nQuality parameter.

The method however has the third parameter.

However this does not change the result.

I've tried the program also on a Vista PC. There is a difference. On that pc there is no file added.

On a Xp PC there is a file created with 0 bytes

Bey

Willy

Posted: Mon Sep 10, 2007 1:14 pm
by Enrico Maria Giordano
Sorry, it is working fine here. I don't know why it does't work for you.

EMG

Posted: Mon Sep 10, 2007 2:03 pm
by Willy
Thanks for trying.

Antonio, do you have any idea.

Willy