Home :: GUI :: Utilities

  1. Introduction
  2. Examples
  3. Download

Introduction

JS-PNG is set of JavaScript objects used to create various types of PNG files. This idea was inspired by Roger Critchlow's Pnglets. Special thanks goes out to Andreas Neumann for pointing out that site.


Examples

The following example creates a simple 32x32 PNG image with three colors, only two of which are visible. A checkboard pattern is created and the final image is displayed in the SVG document using the getBase64() method.

simple_png.svg

This example demonstrates all color spaces, transparency, and alpha channel support currently implemented in JS_PNG. Please note that there appears to be a bug in ASV3 and ASV6pr which causes greyscale images with transparency not to render. Interestingly, all PNG images following that greyscale image will not render either. Please use the following example if you are using either of these viewers.

all_types.svg

This next example partially works around a bug in ASV3 and ASV6 encountered when viewing greyscale images with transparency. My "fix" prevents the effects described above, but apparently transparency is not supported with greyscale and true color PNG images in ASV3 and ASV6.

The greyscale image with transparency continues to display properly in Batik 1.5 in this example; however, the transparency effect is lost in CSV 2.1.

all_types_asv.svg


Download

js_png.zip