PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

alpha blt palmos

Hi,

I just downloaded gapidraw 10 mins ago so please forgive me if this is obvious,

Im trying to target pocketpc and palmos during the design phase of my game, does the palmos support alpha blt using a second alpha surface?

I ask this cos the documentation seems to support CGapiSurface::AlphaBlt for palmos, but I don’t know how you load in the apha surface from a png as CGapiSurface::CreateSurface is only win32 on GDSURFACE_ALPHA.


Actuly while im here are there any unobvious no no’s when targeting palmos (other than the features stated not supported in the docs)

thanks
Hi,

Yes, it supports alpha blends. But not PNG images. So you would have to create two separate image and alpha bitmaps using Photoshop or another tools and load them into two surfaces.
ahh ok,

is this set to change ever, beacuse things like this are mapping out how im going to develop,

ie what formats to make graphics in etc,

also is an alpha blit alot (ie over 20%) slower than a color key?

Edit: thinking about it I don’t see how this would work as youd have to save the image bitmap with a blended background, this would show though the image if it was 50% opaque then get blended with the destination 50%?
You save the image bitmap with a gray (128, 128, 128) background and create a grayscale (0-255) alpha map.

PNG will most probably not make it to the Palm platform in a foreseeable future, so please use split image/alpha bitmaps for cross-platform compatibility. The final Tapwave version of 3.50 will support JPG images through the Tapwave API though...
TGA is a very easy to read graphic format, and support alpha channel.

Not compressed, but it's better to use a compressed archive with all the files anyway..
StephC: Yep. We already provide zip file management on the Palm OS through a virtual file system (to work around that there is no "real" file system available), so TGA is very much a good solution.
StephC you do like your TGA’s :D

Ok, but I cant do that with gapidraw “as is” can i?

Ie save a tga with alpha, and load it into two surfaces for bliting with palmos?
Pejo Software - Per · 05 Oct 2004, 14:05 UTC
[quote="Structure"]
also is an alpha blit alot (ie over 20%) slower than a color key?
quote]
I think alpha blits are substantially slower than normal blits since I don't think you can operate on 2 pixels at the same time there. I am at least not doing it in in my framework, Johan Please correct me if GapiDraw does this.
Pejo:
http://www.develant.com/gapidraw-features.php
"Transparent objects using opacity in GapiDraw all use a super-optimized 32-bit alpha blend function that only uses one multiplication for each pixel (with no look-up-tables)!"

All alpha blends, including those with constant and variable alpha operate on two pixels simultaneously. The alpha blends are also further optimized to only use one multiplication per pixel.


Ie save a tga with alpha, and load it into two surfaces for bliting with palmos?


Yes, you can do that. Simply load the TGA file and store the image in one surface and the alpha information in another surface.
Structure wrote:StephC you do like your TGA’s :D


It's just the oldest, best suited and easiest to use graphic file format for 2D games development.

TGA is to the PNG what WAV is to the Ogg Vorbis.
Johan wrote:

Yes, you can do that. Simply load the TGA file and store the image in one surface and the alpha information in another surface.


woo now ya talkin!

yeah ill go with that, Id just like to thank everyone and point out how good the fantastic level of support this forum offers is.
Pejo Software - Per · 05 Oct 2004, 19:18 UTC
Johan, I guess I expressed myself a little vague. What I really ment was alpha blends with an alpha channel. Alpha blending with with a constant alpha value can of course be done working with 2 pixels at a time resulting in only 1 multiplication / pixel and I am also doing this.
But if you use an alpha channel doesn't this mean that the 2 pixels you operate on has to have the same alpha value.
I actually had an implementation where I tried to operate on 2 pixels when this was the case and on 1 pixel when not, but this did not give any performance increase.
I may be overseeing something here because I see on your webpage that you load the alpha channel into a 16 bit/alpha surface. I only use 8 bit /alpha.
Johan wrote:
Yes, you can do that. Simply load the TGA file and store the image in one surface and the alpha information in another surface.



ok ive been trying to do this for a few mins, am i missing somthing here?

how do you

A)save a tga file with alpha from photoshop?

B)load a tga file as its not supported by the loader?

you can see i got far....... :oops:
Johan, I guess I expressed myself a little vague. What I really ment was alpha blends with an alpha channel. Alpha blending with with a constant alpha value can of course be done working with 2 pixels at a time resulting in only 1 multiplication / pixel and I am also doing this.
But if you use an alpha channel doesn't this mean that the 2 pixels you operate on has to have the same alpha value.
I actually had an implementation where I tried to operate on 2 pixels when this was the case and on 1 pixel when not, but this did not give any performance increase.
I may be overseeing something here because I see on your webpage that you load the alpha channel into a 16 bit/alpha surface. I only use 8 bit /alpha.


You are correct. I'm still a bit jetlagged I guess. GapiDraw does pixel-wise blending on blends with alpha channel. It writes the results using 32-bit 2-pixel writes though. I came to the same conclusion as you did, the extra amount of code is too much for the instruction cache which slows things down compared to the smaller loop.

GapiDraw has two options for alpha. (1) When using CRGBASurface, the alpha is then 8-bit and the color value 16-bit. (2) When using separate surfaces, both color and alpha are 16-bit to simplify things and use the same GapiSurface for both...
ok i got the alpha value into the tga by using a layer mask to crate the alpha channel and saving it as a 32bit/pixel image, is this the correct way?

also i still dont get how to load this into gapidraw?
I take it no one is alpha bliting with a variable alpha map for palmos :(
Of course there are people using alpha blends on the Palm OS, but you are asking many questions without trying to find an answer on your own.

ok i got the alpha value into the tga by using a layer mask to crate the alpha channel and saving it as a 32bit/pixel image, is this the correct way?


I assume that you have managed to create a TGA image file with embedded alpha information. This is a good start. Now you have to get your hands dirty and begin programming.

also i still dont get how to load this into gapidraw?


How much previous programming knowledge do you have? Implementing a simple TGA loader is less than an hour of work even for inexperienced programmers. Just search this forum or google and you will find dozens of C implementations. Once you have the TGA loader done you simply create a CGapiSurface that match the size of your TGA image and set the pixel values of that surface based on your TGA image. If you have no idea what I'm talking about I strongly suggest that you wait with alpha blends and begin with color keyed graphics to get warmed up a bit first.

I would recommend writing your TGA loader on a stationary PC and testing it there. Once you are done you can store the image in a GapiVFS virtual file system on the Palm.
sorry I think misunderstood your previous post when I said

[quote="Structure"]
Ok, but I cant do that with gapidraw “as is” can i?
[quote]

And you said yes, I just assumed that I would not need to add anything like the TGA loader, then i got a bit confused when the createsurface wouldnt load a tga.

yes i can do that, thanks for the info, I appreciate you taking the time to give free development help

Maybe a TGA loader could be a good feature for a future release saving people having to do this, though for the small amount of surfaces I need with varying alpha maps ill probably just use a separate bitmap for the time being.

The reason im coming up with a lot of questions that I could have probably answered over time is that im planning the game out on paper supporting the minimum feature map between palmos and pocketpc, rather than just wading in and getting stuck when there’s a serious design flaw.