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

Username:   Password: 
 RegisterRegister   
 Picture exporting and importing (Hard to explain what I mean)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TheGuyWhoGotOn




PostPosted: Fri Mar 21, 2008 11:34 am   Post subject: Picture exporting and importing (Hard to explain what I mean)

I can't seem to get my picture importing/exporting to work. The checker tries to display the picture but fails every time.
I just want to save a file and make it usable for Turing to use later...
Importer:

Turing:
var Picture :
    record
        Name : string
        Bytes : int
    end record
var FileNumb : int := 1

put "This program will import your picture"
put "Please type the file name (BMP ONLY)"

get Picture.Name

if not(Picture.Name(* - 3 .. *) = ".bmp") then
    put "Invalid File Type"
    quit
end if

Picture.Bytes := Pic.FileNew (Picture.Name)

if Picture.Bytes = 0 then
    put "File Does not exist"
    quit
end if

Pic.Draw (Picture.Bytes, 0, 0, picMerge)

Picture.Bytes := Pic.New (0, 0, 50, 50)

Picture.Name := Picture.Name(1 .. * - 4)

open : FileNumb, "Pics/" + Picture.Name + ".inp", write
        write : FileNumb, Picture
close : FileNumb


Now the checker:

Turing:
var Picture :
    record
        Name : string
        Bytes : int
    end record
var FileNumb : int := 1

Picture.Name := ""
Picture.Bytes := 0

var Name : string

put "What's the picture's name?"
get Name


open : FileNumb, "Pics/" + Name + ".inp", read
read : FileNumb, Picture
close : FileNumb

if Picture.Name = "" then
    put "Picture is invalid"
    quit
elsif not (Picture.Name = Name) then
    put "Picture is invalid"
    quit
end if

if Picture.Bytes = 0 then
    put "Picture is invalid"
    quit
end if

Pic.Draw (Picture.Bytes, 0, 0, picMerge)

put "Picture is valid"


Should I try a different method? I know of no others, thanks.
Sponsor
Sponsor
Sponsor
sponsor
agnivohneb




PostPosted: Mon Mar 24, 2008 1:44 pm   Post subject: Re: Picture exporting and importing (Hard to explain what I mean)

You can't do that.

put this before you open the file in the importer and run the program multiple times with different pictures and names you may see some sort of similarity:
code:
put Picture.Name
put Picture.Bytes

The number is the same!!!!
TheGuyWhoGotOn




PostPosted: Mon Mar 24, 2008 6:31 pm   Post subject: Re: Picture exporting and importing (Hard to explain what I mean)

agnivohneb @ Mon Mar 24, 2008 1:44 pm wrote:
You can't do that.

put this before you open the file in the importer and run the program multiple times with different pictures and names you may see some sort of similarity:
code:
put Picture.Name
put Picture.Bytes

The number is the same!!!!


Wow...Turing doesn't handle pictures well then does it? Well not very advanced...So is there a better method? Or I will I have to have the actual pictures?
agnivohneb




PostPosted: Tue Mar 25, 2008 7:37 am   Post subject: RE:Picture exporting and importing (Hard to explain what I mean)

I think you will need the actual pictures. Try browsing the forum and see if you can find somthing. I'm sure someone did something similar before. But if anyone else has an idea I think you may be stuck with the actual picture files.
Carey




PostPosted: Tue Mar 25, 2008 11:06 am   Post subject: RE:Picture exporting and importing (Hard to explain what I mean)

You can open the picture as a file in read mode, then store all the bytes in a flexible array. you can then do whatever you want with the bytes like write them back to a file, or whatever. There is a bitmap class on this site somewhere. try searching for it.
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 1  [ 5 Posts ]
Jump to:   


Style:  
Search: