Skip to content

A converter from PNG images to formats for use in ZX Spectrum productions.

License

Notifications You must be signed in to change notification settings

robabod/zx-pngconv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Disclaimer

I developed it for use in my own ZX Spectrum projects, and it served its purpose. I put it here with no warranty. Maybe someone will find it useful.

Licenses

This source code is released under the MIT License.

Libraries

PngConv uses:

Both are included in this repository.

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

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 " 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

About

A converter from PNG images to formats for use in ZX Spectrum productions.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published