U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » saving a paletted PNG
Re: saving a paletted PNG [message #6076 is a reply to message #6067] Mon, 30 October 2006 00:10 Go to previous messageGo to previous message
lindquist is currently offline  lindquist
Messages: 33
Registered: March 2006
Location: Denmark
Member
I'm having some more problems.
I have this test code:

void WritePNG(const String& filename)
{
	ImageBuffer ib(256, 256);
	ib.SetKind(IMAGE_OPAQUE);
	
	RGBA pal[256];
	for (int i=0; i<256; ++i)
	{
		pal[i] = Color(i,i,i);
	}
	
	int idx = 0;
	for (int y=0; y<256; ++y)
	{
		RGBA* line = ib[y];
		for (int x=0; x<256; ++x)
		{
			*line = pal[idx%256];
			++line;
			++idx;
		}
	}
	
	PNGEncoder png(8);
	png.SetPalette(pal);
	png.SaveFile(filename, ib);
}


I would assume this code would generate a nice horizontal gradient, but it doesn't. Instead I get something that seems a bit like it's converted to 5bit colors. (every 8 pixels it jumps 16 indexes in the palette)
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: StreamRaster::LoadAnyFile -- not exist in distribution?
Next Topic: Draw Objects with Wallpapers, ...
Goto Forum:
  


Current Time: Sun Sep 27 01:06:57 GMT+2 2026

Total time taken to generate the page: 0.01939 seconds