Table of Contents

CONVERT IMAGES TO MIDRES FORMAT

INTRODUCTION

This page does not want to replace the software user manual (for that there is the README) but to provide some indications on its operation, as well as to explain some of the algorithms used.

OPERATING MODES

The program works in two alternative modes:

UNCOMPRESSED MODE (CBM)

In this mode, the program will read the given image file as input and it will generate two separate files:

The advantage of this mode is that it is compatible with BASIC V2, since the files are saved following the CBM standard. It will therefore be sufficient to launch the LOAD command with the final option ,1 on each of these two files to bring up the overall screen on the screen.

The main disadvantage is that the image is drawn as the system reads it, and this can be an aesthetic problem. Another problem is that this representation takes up more space than the one strictly necessary. For example, on the Commodore 64 a screen occupies a total of 2,004 bytes (about 2 KB).

This is an example of a BASIC image loader for Commodore 64:

  10 if p=0 then 50
  20 if c=0 then 60
  30 poke 53281,0
  40 goto 40
  50 p=1:load "file.pic",8,1
  60 c=1:load "file.col",8,1

This is an example of a BASIC image loader for VIC 20:

  5 if i=0 then 45
  10 if p=0 then 50
  20 if c=0 then 60
  30 poke 36879,8
  40 goto 40
  45 for i=0 to 23*22:print " ";:next i
  50 p=1:load "file.pic",8,1
  60 c=1:load "file.col",8,1

UNCOMPRESSED MODE (ATARI)

In this mode, the program will read the given image file as input and it will generate just one file:

However, the generated file need to redefine the charset using the ztiles.bin charset.

COMPRESSED MODE (CBM)

In this mode, the program will read the given image file as input and it generates a single file:

The main advantage is that this representation takes up less than 50% of the space needed in the uncompressed version. For example, on the Commodore 64 a screen occupies a total of 1,002 bytes. The other advantage is that the image can be reconstructed more quickly than reading from a mass device, and this is more aesthetically pleasing.

The main disadvantage of this mode is that it is incompatible with BASIC V2, and it is necessary to have both a special reader and a support screen. The demonstration program of midres library is a slideshow player that is able to read the compressed format. You have to create the various image files, to update the slideshow file, to modify the makefile and, finally, to rebuild the demonstration program.

IMAGE PROCESSING

The writing of the midres image takes place through a series of automatic processes, which process the image to adapt it to the needs of the medium.

First, if the input and output images are not of the same size, the system will divide the input image into a series of blocks. Each of these blocks will be matched by one of the output mixels.

Since the input blocks are composed of more pixels, the color that will be brought to the output mixel will be calculated as the mathematical average (the “mean”) of the colors of all the pixels.

Each of these “average” pixels will undergo a double parallel process. It will be subjected to comparison with the brightness threshold given on the command line. On the other hand, the software will look for the color of the palette closest to the one we have in input.

The result of these two operations will determine the writing, on the midres bitmap, of the mixel (on or off) and of the relative color attribute.

MIDRES - an isomorphic gamelib