SameBoy icon indicating copy to clipboard operation
SameBoy copied to clipboard

Linux Thumbnails

Open Jan200101 opened this issue 4 years ago • 1 comments

Thumbnails like the ones made by QuickLook on Linux would be neat.

Jan200101 avatar Jan 04 '21 01:01 Jan200101

For Gnome the Thumbnailer spec can be followed but requires png to be created, for which lodepng seems to be a perfect minimalistic dependency with the ability to translate bitmaps to pngs KDE does not follow the Thumbnailer spec it seems so creating a ThumbCreator plugin is the best idea and QImage has the capability to load bitmaps

I have implemented a simple proof-of-concept for the Gnome version by reusing get_image_from_rom from QuickLook and with a bitmap header that creates fully functional bitmaps https://github.com/Jan200101/SameBoy/commit/f4ca66203ab0b153fc91bc729806d96f3644d153

I then used this script sameboy-thumbnailer-png

input=$1
bootrom=$2
output=$3
output_name=$(basename $output)

tmpdir=$(mktemp -d)

sameboy-thumbnailer $input $bootrom $tmpdir/$output_name.bmp
convert $tmpdir/$output_name.bmp $output

rm $tmpdir/$output_name.bmp
rmdir $tmpdir

to convert the bitmap to a png to be compatible with the thumbnailer behavior sameboy.thumbnailer

[Thumbnailer Entry]
TryExec=sameboy-thumbnailer-png
Exec=sameboy-thumbnailer-png "%i" /usr/lib64/sameboy/cgb_boot.bin "%o"
MimeType=application/x-gameboy-color-rom;

(cgb_boot.bin has been hardcoded in this case and should probably be passable as a flag like with the tester and gathered by default if possible) I have locally edited #define LENGTH 60 * 10 present in get_image_from_rom.c to be #define LENGTH 60 * 40 to gather a better image for pokemon but that behavior should be improved upon with something like a forced start button press to get to the title screen (game specific hacks might be needed)

here is the result in nautilus image

Jan200101 avatar Jan 04 '21 12:01 Jan200101