Sprite Converter

discuss pc<>acorn file transfer issues and the use of other utils
Post Reply
User avatar
geraldholdsworth
Posts: 844
Joined: Tue Nov 04, 2014 9:42 pm
Location: Inverness, Scotland
Contact:

Sprite Converter

Post by geraldholdsworth »

Yet another utility I'm making available. This one converts RISC OS sprites to Bitmaps. It is currently called "Sprite Converter", but has previously been known as "!Paint for Windows" and "Sprite to Bitmap Converter" (I dropped the 'bitmap' bit because I intend to output to PNG as well).

This is beta, and is very rough and ready. But, it works and serves it's purpose. Doesn't do, well, a lot of things...but one major omission is masks - sorry about that.

I actually resurrected this one because I needed to convert some sprites for Disc Image Manager, so I ported this across from Delphi and compiled for macOS and Linux (and, of course, Windows). I can compile it for ARM Linux, if anyone wants it.

I won't be developing this for a while - concentrating on Disc Image Manager for now, but I have seen some posts here asking about converting sprites.

As usual, full source code and binaries are here.
User avatar
ash73
Posts: 196
Joined: Wed Feb 03, 2016 10:51 pm
Location: Cheshire, UK
Contact:

Re: Sprite Converter

Post by ash73 »

A tool to convert the other way would be useful, to create RISC OS sprites from BMP/PNGs, given that paint programs on the Archie (such as Atelier) don't seem to be public domain for some bizarre reason.
User avatar
geraldholdsworth
Posts: 844
Joined: Tue Nov 04, 2014 9:42 pm
Location: Inverness, Scotland
Contact:

Re: Sprite Converter

Post by geraldholdsworth »

ash73 wrote:
Sun Jan 31, 2021 2:33 pm
A tool to convert the other way would be useful, to create RISC OS sprites from BMP/PNGs
Excellent idea - I've added it to the list.

I might add the masks sooner rather than later - I just spent the best part of two days converting 300 bitmaps to PNG putting in transparencies (although, because I used Photoshop, it was fairly easy - per bitmap). I'm actually wondering if, because of the transparencies, whether just to export the sprites to PNG only, and not bother with BMP.

I've also noticed that in Linux, at least, the open file dialogue doesn't list all files, particularly if they don't have an extension (which sprite files are likely not to, but just end in ',FF9'...unless you use Disc Image Manager to export them, of course).

And, finally (for now), ARM Linux binary is now available.
User avatar
Richard Russell
Posts: 2140
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Sprite Converter

Post by Richard Russell »

geraldholdsworth wrote:
Mon Feb 01, 2021 5:17 pm
I'm actually wondering if, because of the transparencies, whether just to export the sprites to PNG only, and not bother with BMP.
Although not exactly an 'official' file format, 32-bpp BMPs can have masks (i.e. an 8-bit alpha channel) and are widely supported.
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.
User avatar
geraldholdsworth
Posts: 844
Joined: Tue Nov 04, 2014 9:42 pm
Location: Inverness, Scotland
Contact:

Re: Sprite Converter

Post by geraldholdsworth »

Richard Russell wrote:
Mon Feb 01, 2021 7:30 pm
Although not exactly an 'official' file format, 32-bpp BMPs can have masks (i.e. an 8-bit alpha channel) and are widely supported.
Yep - I did see that, yonks ago. It is in the spec as an alpha channel, but Microsoft specify to leave this fourth byte as zero. But, as you say, it is widely supported.

There is also using the bottom-left pixel as the colour to use as the mask - this relates to the first pixel in the pixel data (as bitmaps as stored bottom-up, or top-down depending on your view). Not sure how widely that is supported though, and not really ideal.
User avatar
Richard Russell
Posts: 2140
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Sprite Converter

Post by Richard Russell »

geraldholdsworth wrote:
Tue Feb 02, 2021 9:50 am
There is also using the bottom-left pixel as the colour to use as the mask
Yet another possibility might be to make a paletted BMP (e.g. 8-bpp) because the palette contains 32-bit entries which presumably can incorporate alpha values. You can make 8-bpp paletted PNGs too so there may be some commonality that you can take advantage of.
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.
User avatar
geraldholdsworth
Posts: 844
Joined: Tue Nov 04, 2014 9:42 pm
Location: Inverness, Scotland
Contact:

Re: Sprite Converter

Post by geraldholdsworth »

It's been a while, but I've been back at this. And, as a co-incidence, I've been asked to increase the size of the text and graphics in Disc Image Manager, and most of the graphics comes from RISC OS (to give it that nice homely feel), particularly the filetypes and I just happen to find some 68x68px sprites, which this tool nicely converted for me to PNG.

So, Sprite Converter is now at 0.01 beta release 4 - I think I'm almost ready to make it version 1 and a proper 'release'. And the changes - I looked at the masks again and perfected them for 4 and 8 bpp sprites. Well, most of them anyway - because I need to add a colour for the mask, I need an entry in the palette. For most of them this is OK, but there is the odd one or two that uses the entire palette. The next step for these ones is to step them up to the next bpp level, but as the PNG output is 32 bit anyway, this shouldn't be an issue.

And that is the other change - it now outputs PNGs, with masks if available. Currently this is only on the 'mass saving' option - I haven't looked at the save single image option yet.

Full source and binaries for Windows, macOS and Linux are here.

Suggestions for future additions are gratefully received (and added to the Documents/Suggestions.txt file).
User avatar
geraldholdsworth
Posts: 844
Joined: Tue Nov 04, 2014 9:42 pm
Location: Inverness, Scotland
Contact:

Re: Sprite Converter

Post by geraldholdsworth »

Richard Russell wrote:
Mon Feb 01, 2021 7:30 pm
Although not exactly an 'official' file format, 32-bpp BMPs can have masks (i.e. an 8-bit alpha channel) and are widely supported.
I actually noticed that I did add the mask with an alpha channel to bitmaps. So, anything that can handle these should see them as a mask.
User avatar
geraldholdsworth
Posts: 844
Joined: Tue Nov 04, 2014 9:42 pm
Location: Inverness, Scotland
Contact:

Re: Sprite Converter

Post by geraldholdsworth »

This has now moved from beta to full release and, as such, has been given a version number of 1.00 - well, 1.01 now. Looks much nicer too - might even make the windows textured like Disc Image Manager.

Anyway, this can now handle most sprites. However, I'm not happy with the handling of transparent bitmaps in Lazarus, so I'm looking at an alternative (still within Lazarus, of course). I also noticed that some, but not all, PNGs exported don't appear with a transparent mask in Adobe Photoshop CS6.

Once I'm happy with the handling of masks, then I'll add the support to Disc Image Manager. However, this will still be actively developed as a stand alone application.

I'm still after some example sprite files: 8 (24bpp),9 (JPEG),17 (4:2:0 YCbCr) and 18 (4:2:2 YCbCr). Plus mode type CMYK (RISC OS 5.21, not the RISC OS 6 variety). If you have such examples, please let me know.
User avatar
geraldholdsworth
Posts: 844
Joined: Tue Nov 04, 2014 9:42 pm
Location: Inverness, Scotland
Contact:

Re: Sprite Converter

Post by geraldholdsworth »

ash73 wrote:
Sun Jan 31, 2021 2:33 pm
A tool to convert the other way would be useful, to create RISC OS sprites from BMP/PNGs, given that paint programs on the Archie (such as Atelier) don't seem to be public domain for some bizarre reason.
I am just about ready to add this functionality to my application. I'm assuming you'll want full backwards compatibility to Arthur?
It appears that sprites have various levels of OS compatibility - Arthur, RISC OS 3.5, RISC OS SIX and RISC OS 5.21. The major difference is the dealing with masks:
Arthur: mask data is the same bpp and size as the pixel data.
RISC OS 3.5: mask data was reduced to 1bpp (transparent or not).
RISC OS 5.21: you could now have an Alpha channel, so mask could be 0-255 (although this is mentioned in the PRM for 3.5 but, apparently, not implemented until 5.21).
RISC OS SIX: only thing I can see is CMYK sprites.

I think I could do some analysis on the incoming image to determine the best mask and bpp to use.
User avatar
IanJeffray
Posts: 947
Joined: Sat Jun 06, 2020 3:50 pm
Contact:

Re: Sprite Converter

Post by IanJeffray »

geraldholdsworth wrote:
Sat Apr 10, 2021 2:06 pm
RISC OS 5.21: you could now have an Alpha channel, so mask could be 0-255 (although this is mentioned in the PRM for 3.5 but, apparently, not implemented until 5.21).
Alpha sprites arrived with Select 3 (RISC OS 4.39) : http://www.riscos.com/support/developer ... annel.html
User avatar
geraldholdsworth
Posts: 844
Joined: Tue Nov 04, 2014 9:42 pm
Location: Inverness, Scotland
Contact:

Re: Sprite Converter

Post by geraldholdsworth »

IanJeffray wrote:
Mon Apr 12, 2021 9:40 am
Alpha sprites arrived with Select 3 (RISC OS 4.39) : http://www.riscos.com/support/developer ... annel.html
Cheers...I'd just discovered that one - I found a pre-RISC OS 5 sprite with an alpha channel. I found a chart on either that website, or the ROOL website (I suspect the latter) which details which features were introduced with with OS version.

I've managed to get Sprite Converter importing PNGs and converting them to sprites (should work for bitmaps and JPEGs too). Needs a bit more testing though, and currently only outputs RISC OS 3.5+ compatible sprites (although outputting an Arthur compatible sprite is just a case of writing the correct mode flag and using a full transparency mask).
User avatar
IanJeffray
Posts: 947
Joined: Sat Jun 06, 2020 3:50 pm
Contact:

Re: Sprite Converter

Post by IanJeffray »

Alpha sprites aren't widely supported, so I'd suggest it'd be useful to have an option to crush to 1bpp mask and/or save the mask as a separate 8bpp sprite.
User avatar
geraldholdsworth
Posts: 844
Joined: Tue Nov 04, 2014 9:42 pm
Location: Inverness, Scotland
Contact:

Re: Sprite Converter

Post by geraldholdsworth »

I've just posted version 1.02 on GitHub. Not finished with it yet, but I need to do some major re-structuring of the code to accommodate what I'm going to do next. This version allows one to import bitmaps, PNGs or JPEGs, which are then converted to a sprite and added to the currently open sprite file (or creates a new one if none are open). There is an option window to select which OS to favour - either Arthur or RISC OS 3.50+. However, if a 16 or 32 bit image is imported when Arthur compatibility is specified, it will still get imported as a RISC OS 3.50+ compatible sprite (as Arthur didn't have 16 or 32bpp sprites). I will enhance this to convert an Alpha mask to a binary mask and add the third option of RISC OS 4.39+. Currently, Alpha masks are added as is, and creates a RISC OS 4.39+ compatible sprite.

I also re-wrote the code to convert the sprites to PNGs natively, and not manually create a bitmap. This means that the resultant exported image is always a 32bpp image.

I've also fixed a few bugs, improved the way some things are done, and texture-tiled the backgrounds.

I'm intending to change the way sprite files are loaded so that they are added to the current open file, instead of closing the current one in favour of the new one. I'll also add in the facility to rename and delete sprites. And, finally, it is not fully High-DPI aware yet, so the text may appear small if you have a high-res display and have 'zoomed in'.

Once I'm happy with the Sprite File class module, I'll be adding this to Disc Image Manager - so you can view sprites direct from a disc image.
Post Reply

Return to “software & utilities for the pc, mac or unix”