1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2026-04-26 10:21:30 +00:00

faster image data using buffer

This commit is contained in:
Steven Hugg
2017-04-06 15:09:30 -04:00
parent a4c40948ea
commit 2667b7051f
7 changed files with 476 additions and 54 deletions
+2
View File
@@ -18,6 +18,8 @@
%.pcx: %.png
convert $< -format raw -type palette -compress none -colors 15 +dither $@
%.4.pcx: %.png
convert $< -format raw -type palette -compress none -colors 4 +dither $@
ship1.pbm: ship1.png
convert ship1.png -negate -flop ship1.pbm
+11 -2
View File
@@ -2,6 +2,13 @@
import sys, array, string
col0 = 0
def tocolor(x):
if x == 0:
return 0
else:
return x + col0
def tohex2(v):
return '0x%02x'%v
@@ -25,13 +32,15 @@ with open(sys.argv[1],'rb') as f:
width = (data[9] << 8) + data[8] + 1
height = (data[11] << 8) + data[10] + 1
rowlen = (data[0x43] << 8) + data[0x42]
print "const byte sprite[] = {"
print "%d,%d," % ((width+1)/2,height)
for y in range(0,height):
ofs = 0x80 + y*rowlen
output = []
for x in range(0,width,2):
b = (data[ofs] << 4) + (data[ofs+1])
b = (tocolor(data[ofs]) << 4) + tocolor(data[ofs+1])
output.append(b)
ofs += 2
print string.join(map(tohex2,output),',') + ','
print "}"