Voir la version complète : [µLibrary][Aide] transparence
Hormis le fait de définir une couleur qui correspond à un alpha de 1 (transparence totale), peut-on définir une transparence pour un sprite, pour le faire apparaitre à moitié transparent par exemple, de manière à encore voir ce qui est affiché derriere?
Soit en utilisant les formats du style PAL3_A5 et là tu as x bits qui définissent la transparence de chaque pixel.
Soit en définissant une transparence globale pour le sprite avec ulSetAlpha.
Hi!:)
So, using normal transparency you have 1bit opaque/transparency for each pixel like with an UL_PF_5551 16-bit pal, but... i would like to have different levels of transparency for my sprites, so it can play as some kind antialiasing... I thought about using UL_PF_PAL5_A3 or PAL3_A5, as i dont need so much color for a sprite and the AA would be cool.
So if i load an sprite saved using a PAL5_A3... the transparency will be on/off or i'll really have 8 levels of alpha (like... 100% opaque, 87,5%, 75%,... 0%)?
And oh well, i couldnt tested it (that's why i ask how it runs), i dont have any program that can save a png with the alpha channel required for PAL5_A3... anyone?
Thaanks! ^^
PS. sorry about english here
In fact there's no way to load files directly to PAL5_A3 or PAL3_A5, I may add this possibility in a future version.
You can however access to the texture data and set the pixels alpha by yourself, it can be a good thing to do in some cases. But if you need a separate channel for alpha in your image and don't have any software that can edit the alpha channel, you can also create and load a second image, which would be in black and white (with grey shades), the grey level representing the alpha level. Then for every pixel, you extract for example the red component of the mask image (they're all equal because of grey) and set the alpha depending on this value, for example:
//For a PAL5_A3 pixel, you first AND the value with 31, keeping only the 5 first bits, those which indicate the color index (giving a value 0 .. 31), then you extract one channel (any of them) from the mask (mask & 31 to keep only the first 5 bits, representing a single channel), shift it so that instead of 5 bits you only have 3 (giving a value 0 .. 7), then shift it 5 bits leftwards to overwrite the alpha part (bits 5 .. 7) of destPixel.
destPixel = (destPixel & 31) | ((maskPixel & 31) >> 2) << 5;
Hmmm when i asked about UL_PF_PAL5_A3 and png's i was thinking about indexed full transparent (not the kind of a gif) png's... there are just a few programs that can save/load this kind of png... today i tried Fireworks, that's one of them... it's a cool thing, as you can drop shadows and fx's like that. And I thought your png loader supported that format... so i was looking for a program to feed it.
Buuut anyway... today, i have seen your update, and wow... i didnt expect it hehe, greeeat work :) So I've been doing some tests :) loading 24bits png files with alpha like PAL5_A3 (knowing that i'm using only 32 colors) runs as expected... i dont know if there's a better way to do this, but it really works for me...
So great great work ... and merciii!! :)
EDIT : More on palettes... hmmm maybe it's me that i'm doing something wrong, but why a paletted PAL8 pic (gif/png) without transparency is loaded with the color nº 255 (0-255) like transparent, when i'm ulDisableTransparentColor just before...
ulDisableTransparentColor();
img = ulLoadImageFilePNG((const char*)Natalie2b, (int)Natalie2b_size, UL_IN_VRAM, UL_PF_PAL8);
Thanks again...
That's normal. In fact the transparency of palette values in PNG files is not supported by my loader. I only support full 32-bit png. In case of paletted PNG, it's only useable if you have a color key and is useful if you expect the colors to be in a certain order.
theNinjaBunny
27/03/2008, 12h00
Hello,
Could someone tell a program to export in PNG format with transparences? I can't find one, i look into Adobe Photoshop CS3, when i put 32bit at image mode I can't export/save in png format.
With 16bit & 5551 I have that all is transparent except the color which have alpha 100% at the image
With 16bit and 5550 I have that the colors have alpha 100% (if the have for example a white of alpha 50% at the image, in the ROM it apeared as white 100%), transparent is only where there's no color at all.
I want to do some "neon-like" images, ONE color per image, some lines that "glow". For example at the same image I want to have white at 100%, white at 75%, white at 50% and white at 25% (and transparence of course). Not more colors.
The solution i thought (if it isn't posible) is to use various sprites at diferents alphas each one, but it's a crappy solution.
NOTE : I doesn't understand so well the solutions proposed here, so, don't get agry if my question is already answered.
Thanks.
In Photoshop, you have to make sure you have a 32bit image, and not a 32bit/component image.
Once you're in 32bit mode, just compose with transparent layers, and you'll be able to export in PNG.
theNinjaBunny
28/03/2008, 00h18
Thanks gorgull, i tried every combination i could thougth but no luck. I have to be missing something. I would apreciate some example files or something to start from there.
I upload my code and my images ( http://www.theninjabunny.com/dpg/GridWars.rar ) the image is whiteplayer32b.png I use only 3 colors (white, white at 50% aprox. and white at 30% aprox ) But i have no image if i use PAL5_A3 or PAL3_A5 ...
I simply got frustrated of trying this... because it has to be a very little thing i'm missing .... T___T
Thanks
vBulletin® v.3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd. Tous droits réservés - Version française vbulletin-fr.org