Game Development Community

Merging images/Getting access to pixels

by baylor wetzel · in Torque Game Builder · 08/02/2009 (4:17 pm) · 4 replies

Is there a way to get access to the raw pixels of an image?

If you're wondering why, i have ~25 images layered on top of each other (obviously, their PNGs with alphas) and i want to compress them down to a single image, which i would then use as an imagemap for a sprite (rather than my current 25 layers mounted to a sprite)

i can't do this in script but maybe somewhere in the very large C++ code base the images are uncompressed into 2-d arrays, allowing me to get specific pixels. In a perfect world, i'd even be able to compress it back to a PNG and save it to disk

#1
08/06/2009 (11:11 pm)
Is this just an art generation issue or something that really has to be handled at run time? If at all possible this is going to be a lot less work to do at development time in an app like GIMP or photoshop.

But if you really need it at run time...

AFAIK there is no helper for this within TGB in script or c++. If there was it would be in the GBitmap class.

But in general you can accomplish this by rendering all the layers to a single texture target which you then keep around to later render to the back buffer all in one draw call. But, I don't know specific how that is done in TGB since I'm not very familiar with its OGL based pipeline.
#2
08/07/2009 (5:45 am)
The type of functions you're looking for have to do with blending, so that's a good starting keyword to look for. Other than that, you're on your own till somebody smarter replies ;)
#3
08/07/2009 (6:19 am)
@James, this needs to be done at runtime. The game is a dress up game where there are 26 clothing types and hundreds of clothes. Right now, i have a sprite with 26 objects (all 256x192 alpha PNGs) mounted to it but the game slows down for some reason, and that's before we've put in animation. If the PC version on a dual core is that slow, i'm scared to see what will happen on the iPhone. So to speed things up, i was going to let the player pick the doll clothes and then we'd merge them into one texture and the game would run a lot faster (it runs plenty fast when the doll only has 2 objects mounted). As a bonus, it would also allow me to unload the original art to save room (assuming i ever figure out how to unload art; this isn't a big deal on the PC but memory is a huge problem on the iPhone)

If there's a different way to do this, i'm open to suggestions :) But because the game is a clothing sandbox, having lots of clothes ends up being a big deal
#4
08/07/2009 (2:50 pm)
There is definately a way to do something like that in the engine. I saw an engine mod that could turn images greyscale (I forget where I saw that though). You could do the same by blending images in the engine and using that blended image as a texture.