Changes

Jump to: navigation, search

Creating images for the Amstrad

1,943 bytes added, 2 July
/* Links */
This converts an image to CPC MODE 0:
*Maximize saturation ('''Colors > Hue-Saturation'''; the CPC palette is very saturated, so this will give a better result)*'''Image > Scale image Image''' to 320xXX (proportional scaling)
*Then scale to 160xXX (non-proportional scaling)
*'''Colors > Posterize ''' with a setting of 3 levels
*Convert to CPC palette ('''Image > Mode > Indexed''', select '''Use custom palette''' and point to the CPC color palette file[http://www.cpctech.org.uk/download/gimp.zip]. Also select '''Remove unused colors''')
*Check '''Image > Image Properties''' for the number of colors used
*Save in a format your converter to SCR understands
===Sample Python program programs for conversion to SCR===
You need to save your image in PPM ASCII format in Gimp for this. Also, Python needs to have NumPy installed. The program will also print the necessary INK statements for BASIC.
 
The first variant is for MODE 0 images:
<pre>
import struct
f = file("cpc3input.ppm", "r") # input filebinfile = open('bin3ouput.scr', 'wb') # output file
pal = [[0,0,0],[255,255,255]] # initial palette
print ik
</pre>
 
For MODE 1 images, replace the second-to-last loop with:
 
<pre>
for cl in range(8): # line in character
for y in range(ydim/8):
for x in range(0,xdim,4):
aa=byte_bin(b[x,y*8+cl])[6:]
bb=byte_bin(b[x+1,y*8+cl])[6:]
cc=byte_bin(b[x+2,y*8+cl])[6:]
dd=byte_bin(b[x+3,y*8+cl])[6:]
oo=(aa[1]+bb[1]+cc[1]+dd[1] +
aa[0]+bb[0]+cc[0]+dd[0])
oo=int(oo,2)
data = struct.pack("B", oo)
binfile.write(data)
data = struct.pack("B", 0)
for t in range(48):
binfile.write(data)
</pre>
 
Finally, here is a program for MODE 2. Input file must an ASCII P'''B'''M this time.
 
<pre>
# Transform PBM image to Amstrad SCR file (MODE 2)
# 2011-08-09
 
from numpy import *
import struct
f = file("input.pbm", "r")
binfile = open('output.scr', 'wb')
 
def byte_bin(x):
r=""
for n in range(7,-1,-1):
v=2**n
if x>=v:
x-=v
r+="1"
else:
r+="0"
return r
 
f.readline()
f.readline()
g = f.readline()
 
xdim, ydim = [int(q) for q in g.split()]
b=zeros((xdim,ydim))
 
x, y = 0, 0
 
while True:
g = f.readline()
if g=="": break
 
for q in g:
if q in ("0", "1"):
b[x,y] = int(q)
x+=1
if x==xdim:
x=0
y+=1
 
for cl in range(8): # line in character
for y in range(ydim/8):
for x in range(0,xdim,8):
oo = 0
for q in range(8):
if b[x+7-q,y*8+cl]==1:
oo += 2**q
data = struct.pack("B", oo)
binfile.write(data)
data = struct.pack("B", 0)
for t in range(48):
binfile.write(data)
 
binfile.close()
</pre>
 
==Links==
 
*[http://code.google.com/p/newoldtv/downloads/detail?name=retro_computing_gimp_0.0.5.tar.gz ''Retro Computing GIMP filters''] (Python filters for GIMP to create optionally dithered images for the CPC, Spectrum, BBC Micro, C64, and Apple II)
*[https://codeberg.org/lightforce6128/gimp-file-cpp-bin-save ''gimp-file-cpp-bin-save''] (GIMP plug-in to save images in CPC format)