Package: c64img
C64img is a python package which provides an abstraction layer for creating
images which Commodore 64 understands. This is especially useful in converting
images created on PC graphics tools, with C64 limitation in mind.This project was inspired byPNG2HIRES_ v0.2 gfx format converter/enthusi
(onslaught), which was initially used as simple graphics converter between
PNG/GIF images to C64 hires (Art studio + executable). It evolved to bunch of
modules, which have own purposes - from simply converting graphics, to
generating data for C64 programs written in cross compilers, or even generating
data for memory optimised animations out of sequence of images.Image2c64Image2c64 is a frontend program toc64imgmodule, which can converts
virtually any image supported byPillowto C64 hires or multicolor formats.
Best results are achieved with filetypes PNG or GIF.As an input 320x200 (multicolor or hires) or 160x200 (mutlicolor) picture is
expected. Mutlicolor pictures will be scaled down to 160x200. Picture will be
converted to 16 colors. During that process some information can be lost, if
used more than 16 colors.Requirements:Python 2.7PillowmoduleInstallationLike other standard Python pro programs,c64imgprovide a convenient way to
install usingsetuptools, so the procedure will look like:$pythonsetup.pyinstallor,pipmight be used as well:$pipinstall-e/path/to/c64img_repositoryor, you can grab latest stable version frompypi:$pipinstallc64imgfinally, if you prefer to use virtualenv:$virtualenv-ppython2venvname$sourcevenvname/bin/activate(venvname)$pipinstallc64imgAfter that, you should be able to accessimage2c64script or importc64imgmodule in Python interpreter.Usage:First of all, check up the switches program provides:$image2c64--helpBesides fine-tuning options like-b/--borderfor selecting border
color,-g/--backgroundfor selecting background color, it allows to
select aprorpiate output format:multi- for pure data located at$6000hires- same, but for hires bitmap and colors ($2000)koala- multicolor bitmap in Koala formatart-studio-hires- high resolution bitmap in Art Studio format (hires
version)Those formats should be passed using-f/--formatparameter.Furthemore two more switches can be used for output format:raw(-r,--raw) - this will produce four files (prefixis
obtained from the input image file name, or by using-oswitch for
output):prefix_bg.raw1-byte file with background color,prefix_screen.raw- screen colors (usually placed at $0400),prefix_color-ram.raw- additional 3rd color (supposed to be placed at$d800)and finallyprefix_bitmap.raw- with bitmap matrix of the pictureexecutable- producesprgwhich can be executed on emulator or real C64.
Note, that this is just a image data and little displayer added to the image
data.For example:Convert PNG image to koala with detailed log:$image2c64-vv-fkoalaimage.pngOutput will be written toimage.prg.Convert GIF image to executable hires image, and write output tooutput.prgfile:$image2c64-fhires-x-ooutput.prgimage.gifConvert several images to raw data. Put the files inoutdirectory:$image2c64-fmulti-r-ooutimage.pngimage1.gifimage2.gifimage3.gifParameter-v/-verbosecan be use multiple times (effective, maximum
amount is double v) which increase verbosity of the output. Using-q/--quiethave opposite effect - it will suppress the output.Color clashesScript can make several things in case of color clashes. In C64 graphics modes
you cannot put pixels in as one like, since there was hardware limitations
(memory, processing power etc), which provided to restrictions in graphics
modes. For example, in standard hires mode (320x200) it is impossible to use
more than 2 colors in 8x8 pixel area.Underneath, c64img provides several options for color clash situation. By using-e/--errorsswitch with one of the following parameter, user can
influence conversion process in case of clashes/errors:no parameter ornone- raport it on the consoleshow- will display it - every wrong area will be marked with red
rectanglesave- will produce file with suffix_error.pngnext to original filegrafx2- will save the error file, and opengrafx2image editor with
original image in front screen and error image on the spare screen. This is
useful for manual clash corrections. Executablegrafx2must be reachable
by the environment variablePATH.fix- willtryto fix the clashes. Note, that this method is pretty
naïve - the approximation of the colors is coarse, and may produce strange
results.Example of output forsaveandfixarguments for--errorparameter:$./image2c64-fmulti-x-esavetest_images/clash.multi.pngERROR: Too many colors per block in char 10, 11 near x=76, y=84.
ERROR: Too many colors per block in char 11, 13 near x=84, y=100.
ERROR: Too many colors per block in char 12, 15 near x=92, y=116$./image2c64-fmulti-x-efixtest_images/clash.multi.pngWARNING: Cannot remap color; using background - 'Light green'$Changes2018-06-12 Added information about possibility to convert picture to chars
(no conversion! Just an info in log!)2015-09-10 Rearranged repository into separate modules for maintainability2014-11-16 Added mechanism for automatic clashes fix2014-11-11 Fixed issue with color clash check in multicolor2014-11-11 Addedgrafx2option into error param. In such case image will
be opened ingrafx2program alongside with the error pic on spare screen.2014-02-09 Rewrite the core of the converter (introducedcharabstraction),
added ability to convert sequence of images.2012-11-20 Added executable output format for multicolor2012-11-19 Added multicolor support, changes to the docstrings2012-11-18 First public releaseLicenceThis software is licensed under 3-clause BSD license. See LICENSE file for
details.