ID:139181
 
Code:
var/icon/I = file("foobar.jpg")
world << I //This works for some reason
I.Scale(50, 50) //Cannot execute null.Scale()

var/icon/I = new("foobar.jpg") //bad icon operation
var/icon/I = new(file("foobar.jpg"))//Returns a blank image


Problem description:

When I read an image from a file, I can't do anything to it except output. When I use any kind of proc, DM crashes and says "Cannot execute null.Scale".

I've been trying all kinds of ways to read in the file, but none of them are working.
var/icon/I = icon('foobar.jpg')
In response to LordAndrew
I'm trying to read in external images that are not part of the project, so that isn't going to help much.

But, as an experiment, I did it that way anyway. I added a jpg to the project and ran this:

var/icon/I = new('foobar.jpg')
world << I


And the output is blank.

EDIT: It's the same with PNG images as well.
In response to Mardok
you dont need new just try by using
var/icon/I = 'foobar.jpg'
world << I<dm> I hope it works for you
In response to Hassanjalil
Yes, that works. Now I have one more question: Can the filename be dynamic at runtime, rather than statically compiling in the files like this?

var/icon/I = 'foobar'
I.Scale(32,32)

In response to Mardok
the other way you can do is create a var
like this
var/icon/Image= iconname or set at the runtime
var/icon/I=Image

and for the scale i think it will work but i am not sure