Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 I am getting random "Illegal picture ID" crashes
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
kha.andrew




PostPosted: Sun Jun 04, 2006 2:19 pm   Post subject: I am getting random "Illegal picture ID" crashes

I am getting random crashes from my program. Here is a sample code
code:
laptoppic := Pic.FileNew ("laptop.jpg")
    laptopresize := Pic.Scale (laptoppic, maxx, maxy)
    Pic.Draw (laptopresize, 0, 0, picCopy)

It isn't always at this code, sometimes at others, but sometimes is also works.

The error message shown is:

Quote:
llegal picture ID number '0'. (Probable cause: picture was not successfully created.).


The picture is in the proper folder, the variable are properly declared

Quote:
var laptoppic : int
var laptopresize : int


I have no idea why its crashing![/quote]
Sponsor
Sponsor
Sponsor
sponsor
TheOneTrueGod




PostPosted: Sun Jun 04, 2006 2:22 pm   Post subject: (No subject)

lol, as it says, "probable cause: picture not created successfully"

This is because you entered the picture name wrong, or the picture doesn't exist, or Turing doesn't support that file extension, or Turing screwed up when resizing it.
kha.andrew




PostPosted: Sun Jun 04, 2006 2:37 pm   Post subject: (No subject)

TheOneTrueGod wrote:
lol, as it says, "probable cause: picture not created successfully"

This is because you entered the picture name wrong, or the picture doesn't exist, or Turing doesn't support that file extension, or Turing screwed up when resizing it.


This picture will sometimes be drawn properly, sometimes not, it crashes at different places. I have this picture drawn many times throughout the whole program and it just crashes any time it wants!

*The piture names are correct, picture DOES exist, it is the correct file extension and is supported
Turing is probably just really buggy.

Anyone have a fix for this.(I lose marks when presenting my program and it crashes.
Cervantes




PostPosted: Sun Jun 04, 2006 3:30 pm   Post subject: (No subject)

kha.andrew wrote:
[
Turing is probably just really buggy.


No, I don't think this is Turing's fault. There are a lot of reasons for this. (TOTG, this might be another question for the FAQ. Smile)


  1. Is the picture in the same folder as the turing program?
  2. Are you absolutely sure you got the name of the file right? Windows has a 'feature' to hide extensions of known file types. This can lead to files named "laptop.jpg.jpg". Turn off that feature (Windows Explorer -> Tools -> Options -> Views or something like that) and check.
  3. Are you sure the file is a jpg file? If you downloaded it as a .gif, say, then just renamed it to a .jpg, it is still a .gif. You need a program (such as MSPaint) to convert between image types.
Mr. T




PostPosted: Sun Jun 04, 2006 4:05 pm   Post subject: Alex's Opinion

When the picture is not in use, use the Pic.Free command to free up some memory space.
zylum




PostPosted: Sun Jun 04, 2006 4:39 pm   Post subject: (No subject)

yeah, if you keep resizing the picture, make sure you free the previous picture or you will run out of memory..
TheOneTrueGod




PostPosted: Sun Jun 04, 2006 4:41 pm   Post subject: (No subject)

That may be the problem, actually.

If you "Pic.Free"d the picture somewhere in your code, then it won't be able to be drawn. Make sure there are no unexpected "Free"ing of your pictures.
kha.andrew




PostPosted: Sun Jun 04, 2006 4:57 pm   Post subject: (No subject)

I would like to make this really clear, the same piece of code that displays a picture will sometimes work perfectly and sometimes just crash unexpectedly. This is most likely not a coding problem.

As for using Free.Pic, I only have a max of about 25 pics, and according to the documentations.

"Turing has a limited number of pictures that are available at any one time (approximately 1,000). "

so I don't think this is a problem.

Anyone else have a fix? Or is turing just Bu99ed
Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: Sun Jun 04, 2006 5:01 pm   Post subject: (No subject)

It's not a truing bug, pleas post more of your code for more help.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
kha.andrew




PostPosted: Sun Jun 04, 2006 5:05 pm   Post subject: (No subject)

code:
%The start of the Submenu for Negative Effects of Techonology on Health
procedure submenu2
    cls
    setscreen ("graphics:550;max")
    %    setscreen ("graphics:max;max")
    Font.Draw ("Loading.....", maxx div 2, maxy div 2, font3, 18)
    ipodpic := Pic.FileNew ("ipod1.jpg")
    ipodresize := Pic.Scale (ipodpic, 550, maxy)
    Pic.Draw (ipodresize, 0, 0, picCopy)
    Font.Draw ("How technology can affect..", 120, 600, font1, 18)
    Font.Draw ("1) your eyes.", 120, 550, font1, 18)
    Font.Draw ("2) your physical fitness.", 120, 500, font1, 18)
    subvar2 := getchar
end submenu2
%The end of the Submenu for Negative Effects of Techonology on Health


%The start of the Submenu for Negative Effects of Techonology and the dependency of it by teens
procedure submenu3
    cls
    setscreen ("graphics:550;max")
    setscreen ("graphics:maxy;max")
    Font.Draw ("Loading.....", maxx div 2, maxy div 2, font3, 18)
    pdapic := Pic.FileNew ("calculator.jpg")
    pdaresize := Pic.Scale (pdapic, 550, maxy)
    Pic.Draw (pdaresize, 0, 0, picCopy)
    Font.Draw ("How technology affects a person's..", 100, 550, font1, 18)
    Font.Draw ("1) language skills.", 100, 400, font1, 18)
    Font.Draw ("2) mental ability.", 100, 320, font1, 18)
    subvar3 := getchar
end submenu3



%The start of the knowledge testing quiz
procedure quizmenu1
    cls
    setscreen ("graphics:max;max")
    Font.Draw ("Loading.....", maxx div 2, maxy div 2, font3, 18)
    laptoppic := Pic.FileNew ("laptop.jpg")
    laptopresize := Pic.Scale (laptoppic, maxx, maxy)
    Pic.Draw (laptopresize, 0, 0, picCopy)
    Font.Draw ("Can technology have bad effects on teens and also", 200, 570, font1, 18)
    Font.Draw ("everyone else?", 200, 540, font1, 18)
    Font.Draw ("1) Yes.", 210, 490, font1, 18)
    Font.Draw ("2) No.", 210, 440, font1, 18)
    Font.Draw ("3) Only if you watch TV.", 210, 390, font1, 18)
    Font.Draw ("4) What is technology?", 210, 340, font1, 18)
    quiz1 := getchar
end quizmenu1




%quiz menu #2
procedure quizmenu2
    cls
    setscreen ("graphics:max;max")
    Font.Draw ("Loading.....", maxx div 2, maxy div 2, font3, 18)
    laptoppic := Pic.FileNew ("laptop.jpg")
    laptopresize := Pic.Scale (laptoppic, maxx, maxy)
    Pic.Draw (laptopresize, 0, 0, picCopy)
    Font.Draw ("Can a computer affect the language skills of a person,", 200, 570, font1, 18)
    Font.Draw ("in a negative way?", 200, 540, font1, 18)
    Font.Draw ("1) Only if you are dumb.", 210, 490, font1, 18)
    Font.Draw ("2) No.", 210, 440, font1, 18)
    Font.Draw ("3) Only if you use MSN Messenger.", 210, 390, font1, 18)
    Font.Draw ("4) Yes.", 210, 340, font1, 18)
    quiz2 := getchar
end quizmenu2


here is more of the code
Dan




PostPosted: Sun Jun 04, 2006 5:12 pm   Post subject: (No subject)

Well if you keep calling thos over and over you deftaly will run out of free pics and get an error.

See just b/c you put a new value in the var dose not mean it gets ride of the pic. The pic is still loaded in to turing just now you do not have anything pointing to it.

I whould try Pic.Free ing the pic you loaded at the end of each of thos procedures.

Also when you scale a pic it creates a new one, so you should also free thos at the end of the procedures as well.

So at the end of each one add somthing like:

code:

Pic.Free(laptoppic)
Pic.Free(laptopresize)
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
kha.andrew




PostPosted: Sun Jun 04, 2006 5:48 pm   Post subject: (No subject)

Thanks, works great!!

Hasn't crashed ever since I put it in.
Very Happy
kha.andrew




PostPosted: Sun Jun 04, 2006 6:17 pm   Post subject: (No subject)

Ok, I take back what I said. It just crashed!! Big time! Everything I've done in the last 2 hours is gone! The whole Turing program Crashed, its says the back will be saved as filename.sav but its not there!

OMG!
I should really try and save more ofter, or even better Turing should AUTOSAVE!
zylum




PostPosted: Sun Jun 04, 2006 10:11 pm   Post subject: (No subject)

kha.andrew wrote:
Ok, I take back what I said. It just crashed!! Big time! Everything I've done in the last 2 hours is gone! The whole Turing program Crashed, its says the back will be saved as filename.sav but its not there!

OMG!
I should really try and save more ofter, or even better Turing should AUTOSAVE!


if it said its saved, then it should be.. it just might be saved somewhere else Confused try looking in your turing directory or elsewere..
zylum




PostPosted: Sun Jun 04, 2006 10:21 pm   Post subject: (No subject)

also, make sure you free all pictures that you dont need any longer. it might have crashed because you missed one.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: