PNG image with different palettes

Blitz3D Forums/Blitz3D Programming/PNG image with different palettes

Massimo32(Posted 2005) [#1]
I need to load the same PNG image but each time using a different color palette. I'm using Blitz2D. Any idea?

Ciao,
Massimo


big10p(Posted 2005) [#2]
I don't know what you mean - blitz doesn't support palette graphics modes.


GfK(Posted 2005) [#3]
You can only use indexed colours in 8-bit graphics modes, which Blitz does not support.


_PJ_(Posted 2005) [#4]
Perhaps loading the image, locking the image buffer and using Read/Write pixel fast???

(um.. does Blitz2D have those commands?)


Massimo32(Posted 2005) [#5]
The image is stored as png and has a 256 colors palette.
I need to change some of the colors.

At present I load the image, then I use Read/Write pixel fast (yes, Blitz2d has these commands)
The image is big, then it's quite a slow way...

...

Using an image editor, it's easy to change a color in the whole image since they're mapped in the palette.
You don't need to change every single pixel, but you can simply change that color in the palette.

...

Well, the image saved in png format should have some kind of palette containing the colors.

I wonder if I can load the image using a different (e.g. external) palette.
Or change the palette in the file (without loading the image in memory).


GfK(Posted 2005) [#6]
Dunno about that. Try www.wotsit.org


Damien Sturdy(Posted 2005) [#7]
You *could* read up on the png format and create modified versions of the original file?


Massimo32(Posted 2005) [#8]
I will try this way...

Thanks to everybody!

Ciao.


Massimo32(Posted 2005) [#9]
It works!

In paletted png images there's a palette chunk, ending with a crc. I do this:

1) load the file .png
2) find the palette chunk
3) change the color in the palette
3) find the new crc of the chunk & overwrite the old one
4) save the new file

It's very fast, if someone is interested I posted a sample code:
http://blitzbasic.com/codearcs/codearcs.php?code=1326