Last modified on 22 July 2015, at 13:32

Img2CPC

Revision as of 13:32, 22 July 2015 by Ronaldo (Talk | contribs)

Img2CPC is a command line tool, developed by AugustoRuiz using C#. You will need the .NET Framework 2.0 to run it properly.

Usage: 

Img2CPC [/w=width] [/h=height] [/g] [/bn=tileBaseName] [/m=mode] 
        [/t] [/f] [/o=output] [/c=80] [/cbb] files 

* w:    Tile Width. If not specified, it will process the whole image width. 
* h:    Tile Height. If not specified, it will process the whole image height. 
* g:    If specified, it will generate one bmp file per tile. 
* bn:   Base name to be used for asm labels. 
* m:    Pixel mode. Valid values are 0,1,2. If not specified defaults to mode 0. 
* t:    Transparency. Creates masks for transparent pixels. 
* i:    Interlace masks. Creates masks for transparent pixels, mixing them with sprite data. 
* f:    Flipped values LUT. Creates a look-up table with flipped bytes for the current mode. 
* o:    Output file name. Default value is gfx.h 
* c:    Create compiled sprites. Screen width in bytes can (should) be specified. (Default 
        width is 80). File name will be compiled.[outputFileName] 
*cbb:   Create backcuffer compiled sprites. File name will be bb.compiled.[outputFileName] 
*files: List of files to process. Wildcards can be used (*.png)

You can specify Img2CPC the palette you want to use. Depending on the mode specified, the program will reduce the number of colors of the original image to 16 colors (mode 0), 4 colors (mode 1) or 2 colors (mode 2). To change the palette that the program uses, you can modify the Img2CPC.exe.config file, which is a XML file.

There is a node in that file like this:

 
  <add key="PaletteColors" 
       value="244,0,244#0,0,132#0,132,132#0,244,132#132,0,0#132,132,0#132,244,0#
              132,0,132#132,132,132#132,244,132#0,0,0#244,132,0#244,244,0#
              244,132,244#132,132,244#244,244,244"/> 


Please, do not change the key, just the value. The value of this node represents the palette colors in RGB, using commas to separate the color components, and a sharp to separate the colors.

There is another node like this:

 <add key="TransparentColor" value="0"/> 

Which specifies the color that will be assumed as transparent (in this case, it will be the first color in the palette). This is only taken into account if you want to create sprites (tiles with masks) or precompiled sprites.

The color reduction is performed using a nearest color algorithm, so the original image can have as many colors as you want (although you will get better results if the original image has the same palette you specify in the config file). The "g" switch can be useful to check the color reduction results without having to use a CPC emulator.

Latest versions of Img2CPC are included in the CPCtelera game engine.

Download Img2CPC