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

Username:   Password: 
 RegisterRegister   
 pic creator
Index -> Programming, Turing -> Turing Submissions
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
agnivohneb




PostPosted: Sun Nov 11, 2007 3:02 pm   Post subject: pic creator

This is just a quick program i made when i was bored.

Pic Creator

WARNING: This Program is still in the Beta stage and errors may occur.

This program allows you to convert a .bmp or .jpg file to a turing readable .t file using the View.WhatDotColor (x, y) function. This is useful if you are creating a game (eg. mario) that uses moving pictures and you want to be able to compile it to an .exe file and send it to everyone but you don't want to have all of those picture files following allong. Why not just use this program and convert your pictures to a format turing recognizes and compile them with your program. All of your pictures are now in one .exe file. No need for a .zip folder!

To use this program just copy your pic to the same dir as this program and enter the file name (don't forget the extension) into the program. It automatically will do the rest. and export it as a .t file.

NOTE: Colour loss may occur. Only use small images.



pic creator (beta).zip
 Description:

Download
 Filename:  pic creator (beta).zip
 Filesize:  391.14 KB
 Downloaded:  182 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
CodeMonkey2000




PostPosted: Sun Nov 11, 2007 4:33 pm   Post subject: RE:pic creator

Wow that's pretty cool. Did you try using turing RGB.GetColour and RGB.SetColor functions? I think you get a better variety with that.
agnivohneb




PostPosted: Sun Nov 11, 2007 5:37 pm   Post subject: RE:pic creator

Thanks I will try that and post a update
agnivohneb




PostPosted: Sun Nov 11, 2007 6:28 pm   Post subject: RE:pic creator

Just tried and there is no difference.
Nick




PostPosted: Sun Nov 11, 2007 6:30 pm   Post subject: Re: pic creator

agnivohneb @ Sun Nov 11, 2007 3:02 pm wrote:
NOTE: Colour loss may occur.


wouldnt RGB prevent this?
StealthArcher




PostPosted: Mon Nov 12, 2007 7:23 pm   Post subject: Re: pic creator

The functions you refer to only read turings default colors.
SNIPERDUDE




PostPosted: Mon Nov 12, 2007 8:32 pm   Post subject: Re: pic creator

lol, I made a programme like this about a year ago. I kinda cheated though: I stored all of the RGB info in a text file (using a VB programme I made to get the RGB data, the turing whatdotcolour isn't that good), then made a corresponding turing program that converted the text file info into the pic.

It works though... Very Happy
agnivohneb




PostPosted: Tue Nov 13, 2007 6:24 pm   Post subject: Re: pic creator

momop @ Sun Nov 11, 2007 6:30 pm wrote:
agnivohneb @ Sun Nov 11, 2007 3:02 pm wrote:
NOTE: Colour loss may occur.


wouldnt RGB prevent this?

I did try but it stays the same colours and it was to confusing to get working. I just gave up and used turings default colours.
Sponsor
Sponsor
Sponsor
sponsor
agnivohneb




PostPosted: Tue Nov 13, 2007 6:36 pm   Post subject: Re: pic creator

Sorry to post 2 messages so quickly but I have uploaded the source and a new license (by-nc-sa). Please respect the license. Have a look at it and upload any changes. Beta projects should not have just one person working on them.


pic creator (beta).zip
 Description:
Updated
Includes Source and License

Download
 Filename:  pic creator (beta).zip
 Filesize:  391.52 KB
 Downloaded:  114 Time(s)

StealthArcher




PostPosted: Tue Nov 13, 2007 10:53 pm   Post subject: Re: pic creator

You will get more help from me when yoiu change it to a gpl license.(Not meant to sound threatening or insulting, but it's hard to do with just text...)


Anyhow, after seeing this, I decided to try and make my own, however, instead of creating another turing file, it creates a binary with your photo in it, all made with View.WhatDotColor, and it has 24bit bitmap quality. I'm serious, I can take any bitmap, turn it into a .tbm with this using whatdotcolor, and turn it back out with drawdot, and it has 24 bit quality.

Now all i have to do is figure out a way to make it take less space than the original bitmap(though it does tkae less space than the .t files this makes).

Any ideas on how to do so? It's still in mega rough format, so dont mind the obvious blights like global vars, and commenting lack.

Turing:
setscreen ("nobuttonbar")
setscreen ("graphics:400;200")
var choice, quality : string := "1"
var n : int
var d : int := 1
var redam, blueam, greenam : real
var yopic : int

proc colorred
    for x : 1 .. 254
        redam := x / 254
        RGB.SetColor (x, redam, 0, 0)
    end for
end colorred

proc colorgreen
    for x : 1 .. 254
        greenam := x / 254
        RGB.SetColor (x, 0, greenam, 0)
    end for
end colorgreen

proc colorblue
    for x : 1 .. 254
        blueam := x / 254
        RGB.SetColor (x, 0, 0, blueam)
    end for
end colorblue

proc mainprogression
    put "Please enter the path to the photo to be converted to a transferrable Bitmap."
    get choice
    yopic := Pic.FileNew (choice)
    var wide, tall, file, tem, wind : int := 0
    var wde, tll, tempo, setup : string
    wide := Pic.Width (yopic)
    tall := Pic.Height (yopic)
    wde := intstr (wide)
    tll := intstr (tall)
    var photocolors : array 1 .. wide, 1 .. tall, 1 .. 3 of int
    wind := Window.Open ("position;top;center,graphics;max;max,offscreenonly")
    Window.SetActive (wind)
    cls
    Pic.Draw (yopic, 0, 0, picCopy)
    RGB.SetColor (0, 0, 0, 0)
    View.Update
    open : file, (choice + ".tbm"), write
    write : file, wde
    write : file, tll
    colorred
    for t : 1 .. tall
        for u : 1 .. wide
            photocolors (u, t, 1) := View.WhatDotColor (u, t)
        end for
    end for
    colorgreen
    for t : 1 .. tall
        for u : 1 .. wide
            photocolors (u, t, 2) := View.WhatDotColor (u, t)
        end for
    end for
    colorblue
    for t : 1 .. tall
        for u : 1 .. wide
            photocolors (u, t, 3) := View.WhatDotColor (u, t)
        end for
    end for
    for r : 1 .. tall
        for p : 1 .. wide
            write : file, photocolors (p, r, 1), photocolors (p, r, 2), photocolors (p, r, 3)
        end for
    end for
    close : file
    put "Bitmap made transferrable."
end mainprogression

proc secondprogression
    RGB.SetColor (0, 0, 0, 0)
    var wide, tall, file, wind, rr, gg, bb : int := 0
    var wde, tll, setup : string
    put "Please enter your transferrable bitmaps file path."
    get choice
    open : file, choice, read
    read : file, wde
    read : file, tll
    wide := strint (wde)
    tall := strint (tll)
    cls
    wind := Window.Open ("position;top;center,graphics;max;max,offscreenonly")
    Window.SetActive (wind)
    cls
    put "Drawing bitmap"
    View.Update
    for r : 1 .. tall
        for p : 1 .. wide
            read : file, rr, gg, bb
            redam:=rr/254
            greenam:=gg/254
            blueam:=bb/254
            RGB.SetColor(1,redam,greenam,blueam)
            Draw.Dot (p, r, 1)
        end for
    end for
    close : file
    View.Update
end secondprogression

put "Welcome to the Transferrable Bitmap File(.tbf) Converter."
delay (500)
put "Would you like to convert a photo?(Bitmap, Jpg, or gif only), or examine a photo?"
View.Update
loop
    get choice
    if choice = "convert" then
        mainprogression
        exit
    elsif choice = "examine" then
        secondprogression
        exit
    elsif choice = "no" then

        exit
    else
    end if
end loop
StealthArcher




PostPosted: Thu Nov 15, 2007 12:53 am   Post subject: Re: pic creator

New version, posting on PSP.


TBMPcreator.t
 Description:

Download
 Filename:  TBMPcreator.t
 Filesize:  4.48 KB
 Downloaded:  165 Time(s)

StealthArcher




PostPosted: Thu Nov 15, 2007 5:54 pm   Post subject: RE:pic creator

No matter what I seem to do I cannot cut down on size....
I've tried strings(dont ask...)
And boolean as well now(why oh why can they not be 1 bit instead of one byte????)

Reals, welll, im not really having the urge to try.....


Any one have any ideas at all to cut down on filespace usage?
Mazer




PostPosted: Thu Nov 15, 2007 7:14 pm   Post subject: RE:pic creator

Is a tbf image bigger than the respective bitmap image?
StealthArcher




PostPosted: Thu Nov 15, 2007 7:38 pm   Post subject: Re: pic creator

Yes, that's why I'm looking for ways to cut down on filespace.

If a boolean was a bit instead of a byte, I probably would just make it under the bitmaps original size.

This is the boolean one.



TBMPbeta2.t
 Description:
The .tbm creator, using boolean conversion.

Download
 Filename:  TBMPbeta2.t
 Filesize:  7.26 KB
 Downloaded:  115 Time(s)

Mazer




PostPosted: Thu Nov 15, 2007 9:30 pm   Post subject: RE:pic creator

You generally don't write single bits. How many booleans are you using anyway? Can you not just store the RGB values?
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

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


Style:  
Search: