#! /bin/bash
INFILE="$1"
OUTFILE="$2"
CONVERTED=`magick "$INFILE" -dither FloydSteinburg -resize 256x256\! -remap ql-palette.png txt:`
if [ -f "$OUTFILE" ]; then
rm "$OUTFILE"
fi
y=-1
s=0
hashstring="#"
IFS=$'\n'
for line in $CONVERTED
do
if [ $y -lt 0 ]; then
y=$[$y+1]
continue
fi
rest=${line#*$hashstring}
position=$(( ${#line} - ${#rest} - ${#searchstring} ))
pixel=${line:$[position]:6}
if [ $s -eq 0 ]; then
byte1=0
byte2=0
fi
if [ $[0x$pixel & 0xFF00] -ne 0 ]; then
byte1=$[($byte1 << 2) | 0x02]
else
byte1=$[$byte1 << 2]
fi
if [ $[0x$pixel & 0xFF0000] -ne 0 ]; then
byte2=$[($byte2 << 1) | 0x01]
else
byte2=$[$byte2 << 1]
fi
if [ $[0x$pixel & 0xFF] -ne 0 ]; then
byte2=$[($byte2 << 1) | 0x01]
else
byte2=$[$byte2 << 1]
fi
s=$[$s+1]
if [ $s -eq 4 ]; then
byte1out=$(printf "%x" $byte1)
byte2out=$(printf "%x" $byte2)
printf "\x$byte1out" >> "$OUTFILE"
printf "\x$byte2out" >> "$OUTFILE"
s=0
fi
done
It will blindly convert any image no matter the size, BUT if you want the aspect ratio to be correct on BBQL then you want to start with an image of 1024x768 or same aspect ratio.
I downloaded the source code from GIT hub, found that my installed version of cmake and ImageMagick required updating. So I downloaded the source code to cmake and ImageMagick, compiled and install onto my system.
The "ql-picture" code compiled with no errors and converted the supplied PNG file to Mode 8 SCR files, which loaded into Fileinfo2 Picture Viewer on SMSQ/E v3.38
I downloaded the source code from GIT hub, found that my installed version of cmake and ImageMagick required updating. So I downloaded the source code to cmake and ImageMagick, compiled and install onto my system.
The "ql-picture" code compiled with no errors and converted the supplied PNG file to Mode 8 SCR files, which loaded into Fileinfo2 Picture Viewer on SMSQ/E v3.38
Nice code...
Can I ask what distro you use? I thought I had set cmake to the one in Ubuntu 20.04!
Nice to hear it works, I need to clean the code a bit and put some error handling!
I am using Linux Mint 19.3, which based on Ubuntu 18.04, but I tried upgrade to Mint 20.04, but 6 months ago there was a few apps tgat needed special attension. I have manually updated many applications, so the system probably cnlose to Mint 20.
I think the offical Mint 20 may be more stable now, so I may look into upgrading the system in the comming weeks.