Register
Site Login
Site Search
Forums
Advertisement
Welcome to PocketMatrix. PocketMatrix is dedicated to providing the best online community for mobile device developers and enthusiests. What's new?

TGA in PF 0_8_1


TGA in PF 0_8_1

Postby dyn » Sep 28, 2005 @ 11:40am

For my game i've changed some files of PocketFrog to add support of uncompressed tga files with alpha channel. You could use it, if you want.


Loading:
AlphaSurface* LoadTGAImage( const uint8_t* pBegin, const uint8_t* pEnd );
AlphaSurface* LoadTGAImage( const TCHAR* filename );
Usage:
Blit as usual Surface.
Blit with transformation will be done as with Surface.

Changed files are in attach (with bugfixes by BIGBEN)

p.s. Bugs not found, but can be!
p.p.s Comments are welcome!
Attachments
pf_tga.rar
support of uncompressed tga with alphachannel
(20 KiB) Downloaded 247 times
User avatar
dyn
pm Member
 
Posts: 17
Joined: Dec 5, 2004 @ 10:05am


Postby BIGBEN » Sep 30, 2005 @ 4:18am

It's very interesting, maybe I'll use it in my future projects.

Can you,please, answer these questions:

As I know TGA supports wide range of bitdepths, can I have 16 bits for color + 8 bits for Alpha channel in my tga file?

Does it load 16bit(not palette based) TGA?

How do you use uncompressed TGA in your project, do you store them in a zip?

Why you decided to use TGA vs. PNG(32)?

Thanks for sharing your work ;)
User avatar
BIGBEN
pm Member
 
Posts: 281
Joined: Mar 18, 2003 @ 10:18pm
Location: Saint-Petersburg, Russia


Postby dyn » Sep 30, 2005 @ 8:59am

BIGBEN wrote:It's very interesting, maybe I'll use it in my future projects.
Can you,please, answer these questions:

No problem 8)

BIGBEN wrote:As I know TGA supports wide range of bitdepths, can I have 16 bits for color + 8 bits for Alpha channel in my tga file?
Does it load 16bit(not palette based) TGA?

Now my code supports only 24bit color and 8bit alphachannel (or without it). :cry:
If it's interesting, i can update my code for support compressed images and various "bitsperpixel".

BIGBEN wrote:How do you use uncompressed TGA in your project, do you store them in a zip?

Yes, i store my images in zip and unzip in memory buffer.

BIGBEN wrote:Why you decided to use TGA vs. PNG(32)?

Afaik, tga load code is simpler and smaller. :) And lpngce doesn't work on my device (on win32 it works fine). Lpngce crashes on read header.

And my question to you: :wink:
You draw images with alphachannel in your Pyromania game, isn't it? How did you do it?
User avatar
dyn
pm Member
 
Posts: 17
Joined: Dec 5, 2004 @ 10:05am


Postby fast_rx » Sep 30, 2005 @ 1:11pm

Dyn,

I've looked at the code, and I see where you made a class that holds an image and alpha...

But when you use the image, do you pass the surface and alpha as separate parameters (using the getAlpha() or whatever it was)? It would be nice to have some way for the blit functions to automatically get the alpha information from the surface (or rather, the alphasurface).
User avatar
fast_rx
pm Member
 
Posts: 660
Joined: Jun 10, 2003 @ 4:24pm


Postby dyn » Sep 30, 2005 @ 2:34pm

I've added to class Surface virtual function that for Surface class always returns 0, and for AlphaSurface returns pointer to alphabuffer.
Also in Rasterizer::Blit() i've added
Code: Select all




if (source->GetAlphaBuffer() != 0)
{
    m_raster->BlitAlpha(...);
}
4 lines; 1 keywds; 1 nums; 18 ops; 0 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  

before m_raster->Blit and m_raster->BlitMask

Is this what you mean?

p.s. So, if AlphaSurface doesn't have alpha channel it'll blited as usual Surface.
User avatar
dyn
pm Member
 
Posts: 17
Joined: Dec 5, 2004 @ 10:05am


Postby fast_rx » Sep 30, 2005 @ 3:09pm

Oh, I overlooked that... That's exactly what I was talking about.

Thanks.
User avatar
fast_rx
pm Member
 
Posts: 660
Joined: Jun 10, 2003 @ 4:24pm


Postby BIGBEN » Sep 30, 2005 @ 8:00pm

dyn wrote:And my question to you: :wink:
You draw images with alphachannel in your Pyromania game, isn't it? How did you do it?


I use Jason's (fast_rx) alpha-blitting code, it uses 2 16bpp surfaces and have amazing blitting speed.

When I release my Demo (soon, all graphics&code done,making levels), you'll see that it doesn't slow the game on 2002+ devices even with lot's of smoke and fire puffs ;) Only on my MIPS device I have noticed a little slowdown.

Thanks for answering my questions, now I'm starting to see the real benefits of your approach. Correct me if I'm wrong, they are:

1. Cross-platform development. I can use the same set of tga files on Win32, PPC 2000 to WMobile 5.0, Symbian(?)
Don't care about is it WM5.0 or not :lol:
This is a very strong benefit(for me).

2. TGA 16bpp. I think here lies another great benefit that could be used by your lib.
First of all TGA is a 'rare' image format that supports 16bpp(not-palette) And 15bpp +1Alphabit(vis/invis). PNG(RGB), JPG and GIF(obviously) don't.
The first benefit here is size and speed on decompression. I'm not sure about the speed but if 16bpp TGA uses the same color scheme as Surface class => speed up could be noticeable.
The second is WYSIWYG - When you convert to TGA 16bpp and look at the image on your PC, the 16bpp would be increased to 24bpp in many viewing programs, but the appearance should be quiet the same as on PPC(in your game).

3. RLE. Is fast'n easy compression-decompression algorithm and it is supported by TGA ;)

4. Zip + TrueVision TARGA. It seems that zip'ed 16bpp TGA will beat zippish PNG(24bpp) file format in both size and speed of loading. Due to LZW Gif should be slower than both. JPG would be much slower.Don't know about 16bpp bmp.

5. Alpha channel. It would be even better if TGA supports 24bpp where 16bpp is for color and 8bpp is for Alpha. The benefits could be obvious.

So, dyn, maybe you found "elixir-stone" !
Cross-platform, small size(zipped/RLE'd), fast on load, lossless, WYSIWYG (16bpp), Alpha channel, Blit() is the same Blit for alpha/no-alpha surfs. What more do we need? ;)

What do you think about 16bpp/RLE support and possibly about 24bpp(16bpp color+8bpp alpha)? And could you,please, provide a link or post a project that uses zip+TGA.

Any other comments are welcome


EDIT:

According to:

http://www.dca.fee.unicamp.br/~martino/disciplinas/ea978/tgaffs.pdf

The Alpha channel IS possible in 24bpp (16bits for color 8bits Alpha channel).
But I do not know is there any free encoding software that supports this.
User avatar
BIGBEN
pm Member
 
Posts: 281
Joined: Mar 18, 2003 @ 10:18pm
Location: Saint-Petersburg, Russia


Postby dyn » Oct 3, 2005 @ 11:11am

rast_fx code really is good, but it's using secondary surface for alphachannel.
My code started from his code (it's a secret :wink:) with one goal - do not use additionally surface to store alpha and support of tga is cool too. :)

1. I cannon say what with Symbian but others will work, i think. But do't foget that this is just addon to PocketFrog and if PF wont work on some platform this code will not work too. :cry:
2. I've tryed to make tga image in PhotoShop7 with 16bit for pixels and 8bit for alphachannel, but i can't. No option to do it. 16/24/32 (32 = 24+8 ) and rle.
3. Yeah!
4. MB, but i don't see any speed testes.
5. I'd like to see your demo with full smoke and fire effects :wink:

BTW :!: I've add rle support :)

ps. Oh, link to my project... www.inscenic.com project: Retro Detonation. No demo yet. But if you want I can drop you it by mail
Attachments
pr_tga_v2.rar
version2. added rle tga support
(23.06 KiB) Downloaded 183 times
User avatar
dyn
pm Member
 
Posts: 17
Joined: Dec 5, 2004 @ 10:05am


Return to PocketFrog & PocketHAL


Sort


Forum Description

SDKs for fast and robust device-independent access to Pocket PC display hardware.

Moderators:

sponge, Kzinti

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron