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
Problem with saving pictures with GflAx [VB]
Moderators: XnTriq, helmut, xnview
-
- Posts: 8705
- Joined: Sun Oct 12, 2003 6:47 pm
- Location: Frankfurt, Germany
Re: Problem with saving pictures with GflAx [VB]
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:
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.
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
-
- Author of XnView
- Posts: 44922
- Joined: Mon Oct 13, 2003 7:31 am
- Location: France