gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Graphics > Having trouble with GFX2GBA...

#132174 - sylus101 - Sun Jun 24, 2007 5:14 am

Okay, here's the deal. I have several images that have 256 colors used.
I'm starting with a 16 bit image, converted and indexed by mtpaint (love that program) to a 256 paletted bmp. The actual project (it's completed for the most part, really) is a card viewer for Magic the Gathering written in DSLua for the NDS.

Now, the problem, is that on some of the pictures, when gfx2gba converts them, that last statement by the utility is that colors used before converting was 256, colors used after 253 (or just something less than 256... I have some that end up 254 or whatever). Colors saved 3.

Many don't do this... several will say 256 before and after with no colors saved. These all turn out looking great. On any that "save" colors I end up with black pixels in several spots on the images. I can't find any reason why this happens to one image and not another. I don't know if it's relevant or not, but I used DL3 Quantize and Floyd-Steinberg (non-quick) in mtPaint for conversion to 256 colors.

I've tried all of the parameters, several that sounded like they would work... and all end up doing the same thing if I try on a picture I know that ends up with the problem.

Does anyone know how to tell gfx2gba NOT to "Save" colors when converting??


Last edited by sylus101 on Sun Jun 24, 2007 8:14 pm; edited 1 time in total

#132187 - tepples - Sun Jun 24, 2007 12:41 pm

Do the black pixels show up if you open the 253-color pictures in another PC-side viewer program? Could I see one of these 253-color pictures to analyze what is going on?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#132222 - sylus101 - Sun Jun 24, 2007 7:25 pm

Of course.

http://72.34.42.221/~sylus101/examples.zip

This is the bmp after conversion by mtpaint, and the output (raw, pal and map) from gfx2gba. The original file (prior to mtpaint) is just a bmp format print screen. Mtpaint is used to resize and then convert.

the parameters I used in gfx2gba were pretty standard:
gfx2gba -pcardname.pal -m -t8 cardname.bmp

I don't know what else I could view the output in. Emulators and direct on my NDS both show the symptom.

#132225 - tepples - Sun Jun 24, 2007 7:48 pm

sylus101 wrote:
Of course.

http://72.34.42.221/~sylus101/examples.zip

This is the bmp after conversion by mtpaint, and the output (raw, pal and map) from gfx2gba. The original file (prior to mtpaint) is just a bmp format print screen. Mtpaint is used to resize and then convert.

Does the one with black dots look like this?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#132226 - sylus101 - Sun Jun 24, 2007 8:05 pm

Yes, exactly. Some end up quite a bit worse, where the text in the image is almost unreadable. Yet, the majority (this is about 1500 different images in all) are okay.

#132230 - tepples - Sun Jun 24, 2007 9:50 pm

What's happening is that palette entry 0 isn't getting set. Normally, palette entry 0 is used for transparency. Is your DS program using extended (16x256) palettes or a plain (1x256) palette?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#132231 - sylus101 - Sun Jun 24, 2007 10:05 pm

Oh boy... I guess I'm not sure to be honest.
Every image has it's own palette, and the command in DSLua to load the raw data, map and palette looks like this:

Background:LoadPalette( "cardnumber.pal" )
Background:LoadTiles( "cardnumber.raw", 256 )
Background:LoadMap( "cardnumber.map", ( 256 / 8 ), ( 192 / 8 ) )

What's going on in PALib underneath all that... I'm not sure. I didn't think backgrounds had transparency, but I suppose if the same utility is converting it they would, wouldn't they.

Here's one that converts fine, I used the exact same process on it (and many others)... can you tell any difference?

http://72.34.42.221/~sylus101/example2.zip

*EDIT* Okay, I'm a dope... I think I've got it, but I'm not sure if I can fix it.
You hit it with position 0 on the palette. All of the ones with the problem don't have black in position 0 like I'd need. I'm trying to use the -a switch in gfx2gba but it doesn't appear to be working... not sure if it's not being read right by DSLua or gfx2gba isn't setting it and/or I'm not using the parameter correctly. I tried both: (black was in position 24 on the palette for one I am testing with)
gfx2gba -a24 -pcard81.pal -m -t8 card81.bmp
gfx2gba -a 24 -pcard81.pal -m -t8 card81.bmp

Neither seemed to work. I did find a way to have mtpaint sort the palette so that black is in the 0 position, so I think I'm going to be okay, I just need to redo a bunch of pictures and I'm not looking forward to it...

Thank you tepples for all of your effort on this.