How to use "png_set_dither"

View: New views
4 Messages — Rating Filter:   Alert me  

How to use "png_set_dither"

by Zhang Ping :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

My graphic device's driver is vga mode and can only support 8bpp. Also, when I want to show a image, I must give the image's palette to the graphic device's driver.
 
In the circumstances, I can use libpng to show a png image which color type is "PNG_COLOR_TYPE_PALETTE", and it performs well.
 
But When I want to show one which color type is "PNG_COLOR_TYPE_RGB" or "PNG_COLOR_TYPE_RGB_ALPHA" and it do not have palletes, I got some problems.
 
I noticed that this function "png_set_dither" can reduce an RGB file to a paletted file. So I created a pallete "std_color_cube" which had 216 entries. I added  "png_set_dither" into
"png_read_png" function.
 
....
png_read_info(png_ptr, info_ptr);
if (info_ptr->color_type ==PNG_COLOR_TYPE_RGB)
{
        printf("From libpng:It is a color_type_rgb!\n");
        png_set_dither(png_ptr, std_color_cube, 216, 216,
            NULL, 0);
 
}
....
 
But when I tried to show a png image which color type was "PNG_COLOR_TYPE_RGB", things looked bad.
I delete this "png_set_dither(png_ptr, std_color_cube, 216, 216,NULL, 0);", and the image look like the one previous.
 
Is there something I overlook or I wrongly used the function "png_set_dither"?
 
I have this abstacle for a long time, and do not know how to deal with it. Is there anybody can help me? Thank you very very much!

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
png-mng-misc mailing list
png-mng-misc@...
https://lists.sourceforge.net/lists/listinfo/png-mng-misc

Re: How to use "png_set_dither"

by Greg Roelofs :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> But when I tried to show a png image which color type was
> "PNG_COLOR_TYPE_RGB", things looked bad.
> I delete this "png_set_dither(png_ptr, std_color_cube, 216, 216,NULL, 0);",
> and the image look like the one previous.

> Is there something I overlook or I wrongly used the function
> "png_set_dither"?

To the best of my knowledge, libpng has never had a high-quality dithering
function (unlike, say, libjpeg).  I think that was more of an early design
goal/hope than a serious feature, though I could be wrong about that.
Virtually every image-decoder I'm aware of has its own ditherer and just
uses image codecs to produce native pixels.

Greg

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
png-mng-misc mailing list
png-mng-misc@...
https://lists.sourceforge.net/lists/listinfo/png-mng-misc

Re: How to use "png_set_dither"

by Cosmin Truta :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, Dec 6, 2008 at 1:41 PM, Greg Roelofs wrote:

> To the best of my knowledge, libpng has never had a high-quality dithering
> function (unlike, say, libjpeg).  I think that was more of an early design
> goal/hope than a serious feature, though I could be wrong about that.
> Virtually every image-decoder I'm aware of has its own ditherer and just
> uses image codecs to produce native pixels.

If libpng dithering is bad, and noone complained about it in years, I
am inclined to believe that noone has used it yet. (Is it being used
in pngquant, BTW?)
And if it is indeed unused, maybe removing it from libpng-1.4 wouldn't
be a bad idea, IMO.

Best regards,
Cosmin

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
png-mng-misc mailing list
png-mng-misc@...
https://lists.sourceforge.net/lists/listinfo/png-mng-misc

Re: How to use "png_set_dither"

by Glenn Randers-Pehrson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Dec 8, 2008 at 3:24 PM, Cosmin Truta <cosmin@...> wrote:

> On Sat, Dec 6, 2008 at 1:41 PM, Greg Roelofs wrote:
>
>> To the best of my knowledge, libpng has never had a high-quality dithering
>> function (unlike, say, libjpeg).  I think that was more of an early design
>> goal/hope than a serious feature, though I could be wrong about that.
>> Virtually every image-decoder I'm aware of has its own ditherer and just
>> uses image codecs to produce native pixels.
>
> If libpng dithering is bad, and noone complained about it in years, I
> am inclined to believe that noone has used it yet. (Is it being used
> in pngquant, BTW?)
> And if it is indeed unused, maybe removing it from libpng-1.4 wouldn't
> be a bad idea, IMO.

OK, it's turned off by default in libpng-1.4.0beta47.

Glenn

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
png-mng-misc mailing list
png-mng-misc@...
https://lists.sourceforge.net/lists/listinfo/png-mng-misc