开发者

How to resize an image in .NET with transparency, both GIFs and PNGs, keeping transparency info

开发者 https://www.devze.com 2022-12-22 03:12 出处:网络
i found a lot of questions about resizing images 开发者_如何学运维in .NET and whatnot, but none of them seemed to talk about resizing images that have transparency (both 1bit like GIFs and w/ alpha ch

i found a lot of questions about resizing images 开发者_如何学运维in .NET and whatnot, but none of them seemed to talk about resizing images that have transparency (both 1bit like GIFs and w/ alpha channel like PNGs), trying obviously to keep that transparency.

Maybe GDI/GDI+ is somewhat lacking of code to easily manage those scenarios or what else? If it's not possible to use .NET as it is, are you aware of any library that can do that, even not free. I just wouldn't like it to be a command line tool (otherwise ImageMagick would probably do the trick easily) for better integration and automation purposes.

Thanks guys. Oh, and gals too.


This is effectively what you are asking Why does resizing a png image lose transparency?


The http://imageresizing.net library preserves transparency when converting between GIF and PNG formats. It's open-source, so you can refer to the source code to see how to achieve it. I believe that the palette generation is key in maintaining transparency, but it's been a while since I made the last change to the GIF and PNG quanitization code - it's been stable for several years.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号