You should not set members of png_ptr_write and info_ptr_write. I don't
know if what you have done is harmless or not, but in future versions
(libpng-1.5.0) you won't be able to do it.
Glenn
On Wed, Jun 30, 2010 at 6:40 AM, Mohit Yadav <mohit.gurgaon@...> wrote:
>
Don't set this directly; png_set_PLTE() will pass this
value in to libpng.
> info_ptr_write->palette.size = ncolors;
Make sure ncolors is 256 or less.
> for(k = 0 ;k< ncolors;k++)
>
> {
>
> palette[k].blue = (png_byte) blue[k];
>
> palette[k].green = (png_byte)green[k];
>
> palette[k].red = (png_byte) red[k];
>
> }
>
> /*set pallete*/
>
> png_set_PLTE(png_ptr_write,info_ptr_write,palette,ncolors );
>
> // info_ptr_write->palette.colors
Don't set these; libpng will calculate them from the color
type and bit depth that you pass in to png_set_IHDR().
> png_ptr_write->channels = 4 ;
>
> png_ptr_write->color_type = 6;
>
>
> png_set_IHDR(png_ptr_write,info_ptr_write,width,height,8,6,0,
> PNG_COMPRESSION_TYPE_DEFAULT,PNG_FILTER_TYPE_DEFAULT
> );
Glenn
|