#79951 - Dark Knight ez - Mon Apr 17, 2006 4:27 pm
Hey all.
Now that I've got sprites displaying, I want to add transparency to some parts of them. Reading through tutorials it is said that the first palette entry specifies the transparent parts of the sprites which uses said palette.
As first palette entry I have chosen pure red (#FF0000). This colour is used as background in the sprites using the palette. When displaying the sprites, however, their red background colour is also displayed and not transparent.
Are their (extra) options which need to be set in order to let sprites use the first palette entry as transparency colour? I couldn't find anything regarding this in the tutorials.
Thanks in advance.
Dark Knight ez
Last edited by Dark Knight ez on Tue Apr 18, 2006 10:28 am; edited 1 time in total
#79953 - pas - Mon Apr 17, 2006 5:01 pm
The only think I think you need to do to add transperency to a sprite or a backround is to make the thing you need transperent in the said purpelred.
Greets:
Pas.
Ps: With Purplered you mean that:[Images not permitted - Click here to view it]
Because that is the color used by DS Programmer to get a file transparent in the DS. If you don't belive me make a .nds file and use a picture and this as transperency in the logo. Then open it in the NDSheader tool and look if it is transparent. And this transperency is for logos and for pictures and sprites in the game.
Last edited by pas on Mon Apr 17, 2006 8:04 pm; edited 1 time in total
#79959 - Dark Knight ez - Mon Apr 17, 2006 6:00 pm
The colour should not make any difference. "Purplered" as you call it, is often used as transparency colour because it is a colour which is not commonly used in sprites.
Some tutorials use black as transparency colour instead, and I've decided to use red.
#79962 - DekuTree64 - Mon Apr 17, 2006 6:12 pm
I use a slightly purple tinted light gray, because I like my eyes to still function after drawing :)
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku
#79965 - Dark Knight ez - Mon Apr 17, 2006 6:30 pm
Meaning you probably got it to work.
Was some specific action needed to enable transparency, or is it present by default?
#79998 - HyperHacker - Tue Apr 18, 2006 12:54 am
Dark Knight ez wrote: |
The colour should not make any difference. "Purplered" as you call it, is often used as transparency colour because it is a colour which is not commonly used in sprites. |
Also because it's RGB 255, 0, 255.
#80244 - Dark Knight ez - Thu Apr 20, 2006 3:33 pm
Apparently I made a mistake with converting my sprite graphics.
I've used the balpalette.bin and balgraphics.bin from the libnds sprite tutorial, and they show up transparent using my display code.
So... if anyone could give a good description on how to create sprite graphics and conver them properly to .bin format, I would be most grateful.
Currently I'm doing the following:
- create a sprite-picture in Adobe PhotoShop with 8bits/channel set.
- convert that picture to "Indexed Color"
.... when doing that I choose for converting with a custom palette, and make sure that the first palette entry is the colour I chose for transparency in the sprite
- saving the sprite-picture as .pcx file
- convert the .pcx file with gfx2gba (version 103)
.... when doing that, I'm using the following command line
.... "gfx2gba.exe in.pcx out.bin -8 -z 256 -b -p out_pal.bin"
Which one of these steps is wrong? Should I not use pcx file? Should I use different gfx2gba options?
#80369 - Dark Knight ez - Fri Apr 21, 2006 7:25 pm
I tried out dovoto's pcx2sprite to no avail. (Same results; no transparency.)
The palette constant which pcx2sprite creates:
Code: |
const u16 font_32x32_digitsPalette[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
....... (same as line above repeated a couple of times)
0x0000, 0x0000, 0x7D33, 0x0000, 0x7FFF, 0x7C1F,}; |
I indeed used four colours, so that's correct I guess. However, when copying this in SPRITE_GFX_SUB with a for-loop, all the colours are at the end of SPRITE_GFX_SUB (index 252 to 255). Shouldn't the transparency colour be at index 0 instead of index 255? Maybe that explains my situation? Any ideas on what I'm doing wrong in that case with creating a pcx file?
If nobody can answer the above questions, but have got sprites working properly, I'd like to ask if you could provide a sample pcx file, with either properly converted .bin-files (graphics + palette) or a properly converted .h-file. This so I can test if it's definitely not something wrong in my code, but with sprite graphics creating and/or converting.
Also, what programs do you use to convert the pcx file to a sprite? And what settings did you use to save the picture as a pcx file?
Thanks in advance.
#82450 - Dark Knight ez - Sat May 06, 2006 2:49 pm
Looking through topics in the Graphics forum, I came across a reply which helped me out. Photoshop inverts the palette (as I noticed using pcx2sprite), so that makes the last palette entry the transparency entry.
This fixed my problem. :)
Posted the "solution" in this old topic, just in case it might be of some help to someone in the future.