Game Development Community

Loading masked images from JPEGs?

by Vern Jensen · in Torque Game Builder · 08/21/2009 (4:51 pm) · 1 replies

In the past, I've seen folks say you can load JPEGs with an alpha mask by creating:

myImage.jpg
myImage.alpha.jpg

You make "myImage.alpha.jpg" have 8 bits (256 colors) and simply put it in the same directory as myImage.jpg, and viola, you have alpha-masked jpegs. Problem is for me, it doesn't work. Is this an old technique that is no longer supported in the current TGB? The thread where this is recommended is from 2007:

www.garagegames.com/community/forums/viewthread/58205

Or am I doing something wrong? I get alpha-masked PNGs just fine, but if I can figure out how to get it to work for JPEGs, I could save a ton of disk space -- my nearly-finished game is now almost a 50 MB download!

[Note: I am on a Mac, so there is a small chance the engine does not support alpha-masked JPEGs on Macs, but does on Windows.]

-Vern

#1
08/26/2009 (3:20 pm)
Okay, so after 2 hours of tinkering around, I've figured out why it wasn't working. Two problems in my case:

1) You must open up managed/datablocks.cs and edit the image's name to NOT include an extension. For example:

imageName = "~/data/images/computer";
NOT
imageName = "~/data/images/computer.jpg";

Torque must try various extensions on its own, and that way it "knows" when it found a JPEG, and it then tries to find .alpha.jpg for the same name.

2) My stupid image editor (GraphicConverter on the Mac) wasn't saving the .alpha.jpg image in 8 bits. It was reconverting it back to 32-bits. Once I used PhotoShop to create the alpha.jpg it worked fine, along with change #1 above.

Hopefully this is helpful to someone else!