icabod.org

PngConv

PNGConv is a PNG to ZX Spectrum Image Convertor. The aim is to allow you to perform image conversions from the command-line, primarily from within a makefile or batch file.

History

v0.0.3 - 06/12/2006
- Fixed a possible problem when using a colour as a mask.
  It could potentially be recognised as image data.
+ Added "-oapp" option to append output to a file.
+ Added "-ohex[=<str>]" option to output as Hex text.
v0.0.2 - 07/11/2006
+ Allow definition of a colour as mask. Overrides use of Alpha channel if
  specified.
+ Allow inversion of image data as well as mask. Default was White = On.
- Shuffled around a loop to remove some duplicate code and make things a
  little more manageable.
+ Added "-odb=" option to provide alternate leading text on output.
v0.0.1 - 06/11/2006
+ First public release.

Instructions

Command Line
============
PngConv [options] input [output]

Detail:

input         : This parameter is required and is the source .png file. There
                is no required format - the image will be converted internally
                to the correct format, providing the image can be read by
                pnglib. Masking for the output sprite is taken from the alpha
                channel of the input, or the specified colour.

output        : This is the output file. If this parameter is not given the
                output will default to "<input>.out".

-h|help       : Display the help.

-ver          : Display version information.

-ss           : Silent mode.

-pos=x,y      : Origin of image to be pulled from the input.
                Defaults to 0,0 (top-left).

-size=x,y     : Size of the output image. Defaults to the size of the input.
                Can be larger than the input.

-mask=<mask>  : Format of the output mask:
                b    : Output only Image (default)
                m    : Output only Mask
                mb   : Alternate Mask and Image bytes
                bm   : Alternate Image and Mask bytes
                mmbb : Alternate Mask and Image lines
                bbmm : Alternate Image and Mask lines

-mc=rgb       : Take mask from the specified RGB colour (3 hex-digits).
                Overrides use of alpha channel for the mask.

-imask        : Invert the mask bits.

-iimg         : Invert the image bits (default is black off, white on).

-ostd         : Send output to stdout (console) rather than a file.
                This option implies -ss.

-otxt         : Output as text.

-odb=<db>     : Set leading text to <db>. Defaults to "db ". Tab characters
                can be entered using "\t". -odb= on it's own gives no
                leading text.

-ohex[=<$>]   : Set text output to Hex format, with optional leading char.
                Default is to output in decimal.
                Defaults leading hex char is "$".

-obin         : Output as binary (default).

-oapp         : Append output (default erases original output file).

-ltr|rtl      : Output left-to-right (default), or right-to-left.

-zz           : ZigZag (alternate lines ltr/rtl).

-usd          : Output upside-down (bottom line first in memory).

Examples of Usage

To convert a simple sprite image:
pngconv image.png image.out
To convert a sprite from a section of an image:
pngconv -pos=20,20 -size=16,16 image.png sprite.out
To output just the mask information:
pngconv -mask=m image.png mask.out
To output the mask information using purple as the mask:
pngconv -mask=m -mc=f0f image.png mask.out
To output the image data as text with "Data<tab>" leading:
pngconv -otxt -odb=Data\t image.png mask.out
To output alternate lines of inverted mask then byte, upside-down, zig-zagging the sprite, as text to stdout:
pngconv -mask=mmbb -imask -usd -zz -otxt -ostd image.png
To output a simple sprite to a hex text file, with leading char of #:
pngconv -otxt -ohex=# -odb=BYTE image.png image.out
To output two sections of an image into a single file:
pngconv -pos=0,0 -size=8,64 image.png image.out
pngconv -pos=8,0 -size=8,64 -oapp image.png image.out

Future additions

  • Output as screen$ format.
  • Support colour.
  • Allow stdin as input (allows piping from another command).