Image object not initalized

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Image object not initalized

Post by PB »

If you run this code (with a valid path to a JPG image) then you get an error
of "Image object not initalized" for the Debug line. This is correct, because
the JPG couldn't be decoded. I know that I should be using "If LoadImage..."
for it. But my suggestion would be that perhaps the error should say that the
UseJPEGImageDecoder() command should be called before loading a JPG?

Code: Select all

LoadImage(0,"Image.jpg")
Debug ImageWidth(0)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Intrigued
Enthusiast
Enthusiast
Posts: 501
Joined: Thu Jun 02, 2005 3:55 am
Location: U.S.A.

Post by Intrigued »

I agree, I ran some code that does rotates an image from the forum here tonight and I saw this error.

The adjustment would help us remember and those new to PB to clue in on the problem, quickly.

(chuckling)

I actually first tried:

Code: Select all

InitImage()
lmao
Intrigued - Registered PureBasic, lifetime updates user
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> I agree, I ran some code that does rotates an image from the forum here
> tonight and I saw this error

Hehe, that's the code I ran to get this error! :) Great minds think alike.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post by walker »

May the answers from Fred & Freak in this post help?
http://www.purebasic.fr/english/viewtop ... =loadimage

This behavior is an intended ....
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Image object not initalized

Post by Trond »

PB wrote: for it. But my suggestion would be that perhaps the error should say that the
UseJPEGImageDecoder() command should be called before loading a JPG?
If the JPEG decoder isn't included then the JPEG file signature (at the start) will be unknown and the file will look corrupted. So that would be a bit difficult, since the whole point with the dynamically added decoders is that the program doesn't know about the other file formats at all until the correct decoder is added.
Intrigued
Enthusiast
Enthusiast
Posts: 501
Joined: Thu Jun 02, 2005 3:55 am
Location: U.S.A.

Post by Intrigued »

Without having these decoders in by default then the program itself can be smaller in size, that seems to be why other formats outside of .bmp where not included by default.
Intrigued - Registered PureBasic, lifetime updates user
Post Reply