BMP2MSX script

By mohai

Paladin (831)

mohai's picture

15-04-2013, 21:11

Hello,

did anybody translate BMP2MSX script tutorial or, at least, has worked with it and understood instructions?

I need to convert some screens and i would like to do it in batch mode, not one by one.

regars

Login or register to post comments

By mohai

Paladin (831)

mohai's picture

02-09-2016, 19:38

I did it long time ago.
I finally translated and adjusted the texts from the Japanese version.
I hope there are no mistakes in the translation, as automatic translation from Japanese is very cryptic and I had to guess the meaning of several sentences.
Some entries are not translated as I did not know how to do it. I chose to keep them untranslated, as somebody with Japanese knowledge could do it.

Here is the help file for the script commands
Here you can find explanation of a bug I found

By samsaga2

Resident (52)

samsaga2's picture

03-09-2016, 09:34

I had write a python script to convert png to screen 2. May be it can be useful to you.

from PIL import Image
import sys


def is_multiple(val, n):
    return val/8 == int(val/8)

def getRow(img, x, y):
    row = [img.getpixel((x+i,y)) for i in range(8)]
    colors = list(sorted(set(row)))

    bg_color = 0
    fg_color = 15

    if len(colors) > 2:
        print("too many colors from {0}x{1} to {2}x{1}".format(x,y,x+7))
    elif len(colors) == 1:
        fg_color = 0
        bg_color = colors[0]
    else:
        fg_color = colors[0]
        bg_color = colors[1]

    bits = ['1' if row[i]==fg_color else '0' for i in range(8)]
    return (int("".join(bits),2), bg_color+fg_color*16)

def getTile(img, x, y):
    row = [getRow(img, x, y+i) for i in range(8)]
    return ([i[0] for i in row], [i[1] for i in row])

def convert(img):
    patterns = []
    colors = []
    for y in range(0,int(img.size[1]/8)):
        for x in range(0,int(img.size[0]/8)):
            pattern, color = getTile(img, x*8, y*8)
            patterns.extend(pattern)
            colors.extend(color)
    return patterns, colors

def save(lst, fname):
    with open(fname, 'wb') as f:
        f.write(bytes(lst))



if len(sys.argv) < 3:
    sys.exit('Usage: %s  ' % sys.argv[0])

img = Image.open(sys.argv[1])

if not is_multiple(img.size[0], 8) or not is_multiple(img.size[1], 8):
    sys.exit('image size must be multiple of 8')

if img.palette == None:
    sys.exit('indexed image expected')

pattern, color = convert(img)
save(pattern, sys.argv[2]+'.pat')
save(color, sys.argv[2]+'.col')

By NYYRIKKI

Enlighted (5356)

NYYRIKKI's picture

05-09-2016, 09:17

mohai wrote:

Hello,

did anybody translate BMP2MSX script tutorial or, at least, has worked with it and understood instructions?

In BMP2MSX you have to select automatic save from the options screen (Output mode/output). After that you can convert all the pictures with same parameters if you just drag & drop all of them at once to main screen.