Game Development Community

Resolved: How to make ImageMap mode = "key" work

by Jason Cahill · in Torque Game Builder · 07/23/2005 (10:54 am) · 3 replies

I'm having some trouble figuring out why this doesn't work. By all accounts it looks like it should. I haven't debugged T2D yet, but maybe someone else has gotten this mode to work.

Here's the image I'm trying to load: mysite.verizon.net/jasoncahill/game-font.png

Yes, I know it has a fixed "cell" width and I could just use "cell" mode. I'm trying to get "key" mode to work, though, and this was a simple image I had laying around.

Here's the datablock definition I'm using
datablock fxImageMapDatablock2D(CourierFont)
{
   mode = key;
   textureName = "~/client/images/game-font.png";
}

When I run in T2D, I get the following console output:
fxImageMapDatablock2D(t2d-font/client/images/game-font.png) - Non POT bitmap loaded padding with approx 58164 bytes of video ram!
fxImageMapDatablock2D::calculateImageMap() - No frames have been acquired! (CourierFont)
t2d-font/client/client.cs (69): Register object failed for object CourierFont of class fxImageMapDatablock2D.

OK, things to note: My bitmap is not a power of two. It's 381x145. Second, my "frames" are fully encased in a one-pixel-wide magenta border, even including the right and bottom. When I pad out the image to 512x256, it claims to "acquire something" but not the 100 frames I'm expecting. I can't seem to make it draw anything with only that change.

Obviously, this datablock definition works:
datablock fxImageMapDatablock2D(CourierFont)
{
   mode = cell;
   textureName = "~/client/images/game-font.png";
   cellWidth = 19;
   cellHeight = 29;
};

Any thoughts?

For s****s & giggles, I've attached a POT version of the image as well: mysite.verizon.net/jasoncahill/game-font2.png. This version results in the following:
fxImageMapDatablock2D::calculateImageMap() - No frames have been acquired! (CourierFont)
t2d-font/client/client.cs (69): Register object failed for object CourierFont of class fxImageMapDatablock2D.

And, lastly, here's a POT version without the magenta in the unused space. This results in no warnings, but doesn't appear to have any frames: mysite.verizon.net/jasoncahill/game-font3.png.

#1
07/23/2005 (1:53 pm)
In that game-font2.png, try padding the image with a color other than the color used for the border key color. Maybe that's throwing it off? Total guess, as I've not tried that mode at all.
#2
07/23/2005 (2:33 pm)
You must use POT as you suspected for this mode but more importantly, you must encode the image correctly. The system starts by looking at the top-left pixel and uses that as the colour-key. Rather than describing the process, you can see example files in the codebase. TGE uses this system to encode GUI skins and you can find these skins in "example\common\ui". Try looking at "darkScroll.png".

In your images, there's no way for T2D to determine what the colour-key is. In-fact, it use "white" which gets it into all sorts of trouble and leads to no frames being acquired.

Hope this helps,

- Melv.
#3
07/23/2005 (6:37 pm)
OK. I've got it now. For those of you who are interested in a help topic on this subject, please look at this thread.

Thanks a ton Melv!