Author Topic: Loading a jpg file into an image  (Read 76 times)

johnaaronrose

  • Newbie
  • *
  • Posts: 5
Loading a jpg file into an image
« on: January 17, 2012, 12:32:56 PM »
I've been looking at someone else's code from a 2007 posting. I'm using Gambas 3.0 with SQLite 3.6.22. I've done a similar piece of coding to that person to get the image from a file.

I get a popup window containing 'Null object' at runtime (which unfortunately does not point at problem line of code, though I think that it must be 'image = Image.Load(Dialog.Path)') with following code, when I click ButtonImportImage:

Public Sub ButtonImportImage_Click()
  Dim image As Image
  Inc Application.Busy
  Dialog.Filter = ImageFileFilter(True)
  Dialog.Title = "Import Image"
  ' load image
  If Dialog.OpenFile() Then Return
  Print "import image path=", Dialog.Path
  image = Image.Load(Dialog.Path)
  ' save image & thumb to temp files
  SaveImageAndThumb(image)
  ButtonExportImage.Enabled = True
Finally
  Dec Application.Busy
Catch
  Message.Warning(ERROR.Text)
End

On execution, TempImagePath is valid and points to a .jpg file which loads with Graphics apps such as gThumbThumbViewer. I'm baffled as to the cause. Any ideas?

Grasping at straws: I'm using Gambas3 with SQLite 3.6.22. I just noticed that Gambas3 has a new component gb.image.io - image loading & saving. If I try and select it (in Project Properties) it seems to be incompatible with gb.gui, gb.gtk & gb.qt4. Perhaps it's needed for the Image.Load line - I need to load an Image for the SaveImageAndThumb procedure (which is working when called by another Sub).
Regards,
John

Linux Basic

Loading a jpg file into an image
« on: January 17, 2012, 12:32:56 PM »