oPicture:SaveImage does not work

Post Reply
Willy
Posts: 117
Joined: Thu Mar 02, 2006 11:06 am
Location: Belgium

oPicture:SaveImage does not work

Post 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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: oPicture:SaveImage does not work

Post 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
Willy
Posts: 117
Joined: Thu Mar 02, 2006 11:06 am
Location: Belgium

Post 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
Willy
Posts: 117
Joined: Thu Mar 02, 2006 11:06 am
Location: Belgium

Post 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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Sorry, it is working fine here. I don't know why it does't work for you.

EMG
Willy
Posts: 117
Joined: Thu Mar 02, 2006 11:06 am
Location: Belgium

Post by Willy »

Thanks for trying.

Antonio, do you have any idea.

Willy
Post Reply