Computer Science Canada

Image not working -- Illegal Picture Number ID '0'

Author:  coderdew [ Wed Apr 30, 2014 4:18 pm ]
Post subject:  Image not working -- Illegal Picture Number ID '0'

What is it you are trying to achieve?
To create a ninja running animation.


What is the problem you are having?
Images are not loading, getting error "Illegal Picture ID Number '0'"

Describe what you have tried to solve this problem
I tried cropping the images so that I would have less white space.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)


Turing:


View.Set("graphics")

var pic1 : int
var pic2 : int
var pic3 : int
var pic4 : int
var pic5 : int
var pic6 : int


pic1 := Pic.FileNew ("ninja1.jpg")
pic2 := Pic.FileNew ("ninja2.jpg")
pic3 := Pic.FileNew ("ninja3.jpg")
pic4 := Pic.FileNew ("ninja4.jpg")
pic5 := Pic.FileNew ("ninja5.jpg")
pic6 := Pic.FileNew ("ninja6.jpg")

loop
    cls
    Pic.Draw (pic1, 50, 50, picMerge)
    cls
    Pic.Draw (pic2, 50, 50, picMerge)
    cls
    Pic.Draw (pic3, 50, 50, picMerge)
    cls
    Pic.Draw (pic4, 50, 50, picMerge)
    cls
    Pic.Draw (pic5, 50, 50, picMerge)
    cls
    Pic.Draw (pic6, 50, 50, picMerge)
end loop




Please specify what version of Turing you are using
<Version 4.1>

Author:  Dreadnought [ Wed Apr 30, 2014 5:32 pm ]
Post subject:  Re: Image not working -- Illegal Picture Number ID '0'

Try loading the pictures with this function which should print out an error message if Pic.FileNew fails.
Turing:
fcn PicLoad (path : string) : int
    const pic : int := Pic.FileNew (path)
    if pic = 0 then
        % An error occured, print an error message and halt
        put "Failed to load \"", path, "\""
        put Error.LastMsg
        Error.Halt(Error.LastMsg + "  (" + intstr(Error.Last) + ")")
    else
        result pic
    end if
end PicLoad


% Example
var myPic :int := PicLoad("mypic.jpg")


You might also be interested to know that although Turing claims to support JPEG format image files, not all JPEGs are supported (must be something like alpha that Turing doesn't like). You might also want to try opening your files in an image editor and then saving them as bitmap images (*.bmp extension).

Author:  Insectoid [ Wed Apr 30, 2014 5:40 pm ]
Post subject:  RE:Image not working -- Illegal Picture Number ID \'0\'

read through this thread: http://compsci.ca/v3/viewtopic.php?p=282951#282951


: