Results 1 to 6 of 6

Thread: Utility: PngIron - Flatten Alpha-PNG image files onto a mask color

Threaded View

  1. #1

    Thread Starter
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Utility: PngIron - Flatten Alpha-PNG image files onto a mask color

    Version 1.1
    02-December-2015
    Robert Riemersma

    This is a small GUI utility intended to help you pre-process small PNG format images that have alpha channel transparency and translucency. Additional work may need to be done on the output saved by this program using another more generalized image editing tool.

    Often programmers using classic Visual Basic need small bitmap images for use in making icons and images for use with common Visual Basic controls. But many times they can find free images that might be useful except for being alpha-PNG images. Instead what is needed is "maskcolor" transparency, or in some cases GIF-transparency will do.

    This program can help iron out or "flatten" alpha-PNG images against a selected maskcolor and save this composited image to disk as a new PNG file. Such a flat PNG can be easier to work with using other tools to make a final product.

    But PngIron is a one-trick pony, not a general purpose graphics tool. Most versions of Windows Paint can be valuable in finishing up, and other tools like the popular IrfanView can help with this stage too.


    Requrements, Installing PngIron

    PngIron consists of a single EXE. You can copy this to any folder and create shortcuts as needed to run it.

    There are no extra DLLs or OCXs to install. However it does make use of WIA 2.0 and Shell32 4.71 or later.

    This means it requires Windows Vista or later. If you have a machine with Windows 2000 SP4 or Windows XP SP1 or later and it has WIA 2.0 installed then it should work there as well. However Microsoft no longer provides the necessary DLL for installation into those unsupported systems. Quote from MSDN:

    Developer audience

    The WIA Automation Layer API is designed for use by Microsoft Visual Basic 6.0, Active Server Pages (ASP), and scripting programmers.

    Run-time requirements

    Applications that use the WIA Automation Layer API require Windows Vista or later. Earlier versions of Windows are not supported.

    Compiling PngIron

    Nothing special is required here. You just need Visual Basic 6.0 (Professional Edition or better) installed on a Windows Vista (or later) PC. It can also be compiled under Windows XP SP1 to SP3 and Windows 2000 SP4 as long as you have the WIA 2.0 SDK installed there.


    What PngIron Does

    First you open an existing alpha-PNG file, which Pngiron will display. If the file has no alpha information PngIron will let you know and things end there.

    Otherwise you can:

    • Set a maskcolor.
    • Choose an alpha threshold level for flattening that eliminates fringing and shadows as desired.
    • "Knock out" stray pixels by replacing them with the maskcolor or selected paintcolors.
    • Reduce the color count via a simple algorithm.


    You can fiddle with the various settings until the image is clean enough for use. Then you can save it as a new PNG file.


    Limitations

    PngIron does not save in BMP format because it is bulky. It does not save as GIF because it doesn't have enough control of the image. Save as GIF would often end up with "dithered" colors.

    Many operations such as a change to the alpha threshold can be slow due to the way PngIron is working with these images. You will want to avoid working with images much larger than 256x256 pixels - they work but things can slow down quite a bit as you make changes.

    No attempt has been made to deal with DPI settings higher than the standard 96dpi display setting.

    With more effort PngIron could be modified to reduce or eliminate these limitations. If you need to do a lot of this you might want to consider more generalized and more powerful image editing tools.


    License

    Microsoft Public License (Ms-PL)

    This is a very permissive license. See the ReadMe.txt in the attachment for full details.


    Attachment

    This containts the precompiled binary PngIron.exe, ReadMe.txt file, and the entire VB6 source for compiling PngIron yourself.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width