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

Username:   Password: 
 RegisterRegister   
 Concept: Composing image-pack to file and back
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Notoroge




PostPosted: Fri May 27, 2005 12:03 pm   Post subject: Concept: Composing image-pack to file and back

I'm working on a game for my final project (which I'll post once it's done), but I'm working on an idea. I want to see if there's a way to compile all these image (frames, for sprites), into one single file (for the sake of making the whole package structure look cooler).

The way I've gone about it so far, is to take all the "text" from all image files and put it in a file called "game.dat", each image being separated by "---", so as to look like so:
code:
fslkgHGlah94thOISgh($*HWv     AoiufgH*GHWG       gKSAGH498g                                    SADKjgh984g
---
GJ 0g04g94gh                                               9q848ogFDGO 039tqjhdogi                                 fh3oqhf        qo3fhqig hdoaig jh
That's not the actual file, but it gives an idea as to what it's like. But I can't take the file line by like in a string because, well, "input string too large for string value". Tried taking it "word" for "word", but it skips all the spaces and causes the outputted BMP to be corrupted.

In fact, I think my whole method is flawed, because I opened an image in notepad. Copied it to my "game.dat" file. Closed it. Renamed "game.dat" to "game.bmp" and it was currupted. So notepad is missing some characters (characters not meant to be displayed, etc).

I'm thinking there's a way to make Turing go through all the files and out-put the game.dat file itself (and possibly not skipping hidden characters).

Another idea would be to zip the files, include a command-line zip-archive extractor, and call it with "Sys.Exec" before running the game.

I'm not looking for code, just ideas. Any thoughts on how to make this work?
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Fri May 27, 2005 12:17 pm   Post subject: (No subject)

Great idea! Actually, this is the basis for the compression in my Sprite engine (which may or may not ever be released).
Of course, trying to read directly from a raw .bmp file is not the best of ideas. So, thing about this: How else could you store information about an image in text format?
Highlight for a hint:


Perhaps, you could figure out the colours, pixel by pixel, and store that somehow?
StarGateSG-1




PostPosted: Fri May 27, 2005 3:07 pm   Post subject: (No subject)

Hey, I am not sure if you can do the above idea, that would almost be above turing, i think aleast. I really like your idea and would like to see how you achevied so far could you mabye post it?
Then I could look over it if you wnat, I know you don't wnat code but maybe I could give better idea's when I see it.
Notoroge




PostPosted: Sat May 28, 2005 9:35 am   Post subject: (No subject)

Make a program that 'whatdotcolours' in an two arrays that are the size of the width and height of a chosen image. Go through all the coordinates and save the colours to a file, then save a line after each image that has the number of width and height? Or maybe the width and height should go before the actual pixel data. That way it'll save a lot of trouble. Having to re-open the file and what-not.

Then in the game, use that data to redraw and new image off-screen. Export that image to a temporary file, and then load it again as a sprite?

Seems like overkill. :/
Delos




PostPosted: Sat May 28, 2005 9:54 am   Post subject: (No subject)

Overkill? Not entirely. You have the right idea set up, so now you can store your pics as text (numebrs) and not only as bitmaps. You could always go the way most people go and leave them as such...
As a note, Turing has awful file management, so if you create a file (using put:) you end up with at minimum 32 kB. I think this is resolved with write:, but I'm not sure.
Bacchus




PostPosted: Sat May 28, 2005 11:20 am   Post subject: (No subject)

ya but if you used whatdotcolor wouldnt you get really blocky looking picture? i mean wouldnt it better if you got it to get the rgb of the color and store those to remake the pic? might take longer but would look better
Delos




PostPosted: Sat May 28, 2005 12:16 pm   Post subject: (No subject)

The problem with RGB is that you still need to use a variant of whatdotcolour to retrieve the specific pixel colours. And since whatdotcolour is limited to Turing's 256 colours...you see where this is going.
That's why Turing doesn't handle those pretty .jpgs that come out of your Digi-cam too well.

If you've figured out how to extract colours at 24bit, please do tell - it would make life so much more interesting.

And if you're working w/ sprites, chances are you'll be using good ol' 256 colours so you wouldn't have to worry too much...
Bacchus




PostPosted: Sat May 28, 2005 2:02 pm   Post subject: (No subject)

ya i kno, thats the problem Sad
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sat May 28, 2005 2:17 pm   Post subject: (No subject)

I don't know if this would work: it's just an idea. Someone else can test it out. Razz
First, Turing can have more than 256 colours (via RGB.AddColour), correct? If so, what if you replaced Turing's standard 256 colours with your own colours, (via RGB.SetColour & RGB.AddColour)? Does whatdotcolour return the nearest colour for that specific pixel in that specific window's colour library, or is a built-in library of colours that we can't access?
Delos




PostPosted: Sat May 28, 2005 6:51 pm   Post subject: (No subject)

It returns the closest value to OOT's 256 colour set. Sadly. What I havn't tried though is to create a bunch of colours w/ RGB and then whatdotcolour a pixel outside of the 256 range. There is a possibility that it would do something good for a change and identify it as one of the ones you'd just created (assuming they were actually the same). Again, a problem is that you can only Add so many colours before Turing runs out of palette space [sigh].
Bacchus




PostPosted: Sat May 28, 2005 8:00 pm   Post subject: (No subject)

hm.. i was testing things and whatdotcolor did seem to return a added RGB color to be used.. may help dunno:
code:
drawfillbox (0, 0, maxx div 3, maxy, 2)
locate (1, 1)
put "whatdotcolor: ", whatdotcolor ((maxx div 3) - 5, maxy div 2)
var r, g, b : real
RGB.GetColor (2, r, g, b)
locate (2, 1)
put "rgb: r-", r, ",g-", g, ",b-", b

var clr : int := RGB.AddColor (r, g + .1, b)
drawfillbox (maxx div 3, 0, (maxx div 3) * 2, maxy, clr)
locate (1, maxcol div 3)
put "whatdotcolor: ", whatdotcolor (((maxx div 3) * 2) - 5, maxy div 2)
RGB.GetColor (whatdotcolor (((maxx div 3) * 2) - 5, maxy div 2), r, g, b)
locate (2, maxcol div 3)
put "rgb: r-", r, ",g-", g, ",b-", b

var clr1 : int := RGB.AddColor (r, g + .2, b)
drawfillbox ((maxx div 3) * 2, 0, maxx, maxy, clr1)
locate (1, (maxcol div 3) * 2)
put "whatdotcolor: ", whatdotcolor (maxx, maxy div 2)
RGB.GetColor (whatdotcolor (maxx, maxy div 2), r, g, b)
locate (2, (maxcol div 3) * 2)
put "rgb: r-", r, ",g-", g, ",b-", b
Delos




PostPosted: Sat May 28, 2005 8:25 pm   Post subject: (No subject)

This is good. But then it leaves us with the problem of having to guess at the many possible colours that are present in a good pic.
However...since RGB can produce around 1000+ colours, one might actually be able to make something of it...hmm...
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  [ 12 Posts ]
Jump to:   


Style:  
Search: