Problem with saving pictures with GflAx [VB]

Discussions on GFL SDK, the graphic library for reading and writing graphic files

Moderators: XnTriq, xnview

Erik

Problem with saving pictures with GflAx [VB]

Post 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
User avatar
helmut
Posts: 8226
Joined: Sun Oct 12, 2003 6:47 pm
Location: Frankfurt, Germany

Re: Problem with saving pictures with GflAx [VB]

Post 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.
Erik

Post by Erik »

Thanks, I.ve got it to work. Would you know how to save tiff files in compressed format using the DLL version?
User avatar
xnview
Author of XnView
Posts: 36409
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Post 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.