Page 1 of 1

Problem with saving pictures with GflAx [VB]

Posted: Sat Dec 06, 2003 2:25 am
by Erik
I have problems with trying some code to save a picture from a standard picturebox in VB. It crashes when I ultimately want to save the file. The code I use is as follows (where picturebox is the standard picturebox on the form that holds the image):

m_strFileName = "D:\Test\Block.jpg"

Dim Myobj As GflAx193.GflAx
Set Myobj = New GflAx193.GflAx

Myobj.SaveFormat = AX_JPEG

Myobj.SetPicture pictureBox
Myobj.SaveBitmap m_strFileName ' this is the code that fails

Set Myobj = Nothing

What am I doing wrong or do you know what's going on?

Erik

Re: Problem with saving pictures with GflAx [VB]

Posted: Sun Dec 07, 2003 12:05 pm
by helmut
First I must say, that I'm a real GFL SDK newbie, so my advice might be completely wrong.

The error code raised would help to find the problem. I assume that you get a "-2147220504 No file opened".

Since you do not load an existing bitmap using GFL SDK, I assume that you have to call NewBitmap first. So your code should change to something like:

Code: Select all

m_strFileName = "D:\Test\Block.jpg"

Dim Myobj As GflAx193.GflAx
Set Myobj = New GflAx193.GflAx

Myobj.NewBitmap pictureBox.Width, pictureBox.Height
Myobj.SetPicture pictureBox
Myobj.SaveFormat = AX_JPEG
Myobj.SaveBitmap m_strFileName

Set Myobj = Nothing
I am not quite clear and sure how to set the width and height parameters of .NewBitmap properly, but for me the code did work.

Posted: Wed Dec 10, 2003 12:52 pm
by Erik
Thanks, I.ve got it to work. Would you know how to save tiff files in compressed format using the DLL version?

Posted: Thu Dec 11, 2003 1:55 pm
by xnview
Erik wrote:Thanks, I.ve got it to work. Would you know how to save tiff files in compressed format using the DLL version?
Change Compression in GFL_SAVE_PARAMS.
Pierre.