Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

Ads

#1 2023-11-12 16:02:40

drev
New member
Registered: 2022-10-30
Posts: 8

png2asset with black and wite png (no grayscale)

Hello, I am using png2asset on a png file that contains only  black on white  https://github.com/odrevet/gbdk-projects/blob/124792788db27864bfaa0c45bfb95687ac05b956/games/marioland/assets/text.png?raw=true

Code:

png2asset "./assets/text.png" -c "src/graphics/text.c" -spr8x8 -tiles_only -noflip # noflip because W is a reversed M

The generated tiles are however not black on white but grey on white (#aaaaaa)

Code:

const uint8_t text_tiles[608] = {
    0x00,0x00,0x3c,0x00,
    0x66,0x00,0x66,0x00,
    0x66,0x00,0x66,0x00,
    0x3c,0x00,0x00,0x00,
    
0x00,0x00,0x18,0x00,
    0x38,0x00,0x18,0x00,
    0x18,0x00,0x18,0x00,
    0x3c,0x00,0x00,0x00,
    
0x00,0x00,0x3c,0x00,
    0x4e,0x00,0x0e,0x00,
    0x3c,0x00,0x70,0x00,
    0x7e,0x00,0x00,0x00,

...

when I put a grey pixel anywere in the source png file, the text is black.

Is it a known issu with png2asset or did I missed a flag ?

Last edited by drev (2023-11-12 16:04:39)

Offline

 

#2 2023-11-13 07:27:49

toxa
Member
Registered: 2020-02-13
Posts: 307

Re: png2asset with black and wite png (no grayscale)

1. why do you use the metasprite mode, while it is much better to use the tilemap mode (-map, not -spr8x8)?
2. you can use indexed PNG with only 4 colors and use -keep_palette_order.

Last edited by toxa (2023-11-13 07:28:04)

Offline

 

#3 2023-11-14 00:41:07

drev
New member
Registered: 2022-10-30
Posts: 8

Re: png2asset with black and wite png (no grayscale)

Thank you, it worked using -keep_palette_order and indexed mode.
For information, under gimp I changed to indexed color mode using the image/Mode menu and selected 4 colors
https://docs.gimp.org/en/gimp-image-con … dexed.html
Since the image only have 2 colors the I had to manually add 2 more colors using the Colormap dialog
https://docs.gimp.org/en/gimp-indexed-p … ialog.html

Last edited by drev (2023-11-14 00:44:18)

Offline

 

#4 2023-11-14 05:17:25

toxa
Member
Registered: 2020-02-13
Posts: 307

Re: png2asset with black and wite png (no grayscale)

yes, usually, when you have more or less large project with many assets, it is important to make conversion process predictable and same for all the images in the project. -keep_palette_order and indexed png images is the best way to achieve that

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson