Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Converting images to tiles - workflow tip regarding palette preservation

Reply to topic
Author Message
  • Joined: 23 Mar 2013
  • Posts: 611
  • Location: Copenhagen, Denmark
Reply with quote
Converting images to tiles - workflow tip regarding palette preservation
Post Posted: Mon Apr 11, 2016 10:06 am
Hi,

I use BMP2Tile to convert my images to tiles, but I don't think I have an optimal workflow when it comes to handling the palette. I'll try to explain below.

When I draw my sprites in Paint Shop Pro or Sprite Something (iPad), I don't necessarily use the full 16 color sprite palette. For example: Swabby the snail has the transparent background and some yellow and red colors. Let's say these colors are on palette indexes 0-6 (on the sprite palette). Then, in antoher spriting session, I draw a zombie (one of Swabby's enemies). This zombie shares the background color with Swabby (of course), but uses different purple and blue colors, which can fit nicely into the top half of the sprite palette (lets say from 7-11). Swabby and the zombie needs to co-exist on the same screen, so they need to share the palette. This is all well, but when I process the zombie, BMP2Tile does not include the unused colors (Swabby's colors) in the tile definitions and the palette. The palette set up in Paint Shop Pro is discarded by BMP2Tile.

I can work around this by collecting all the sprites into a sprite sheet and then process the entire sheet. But then I have a hard time figuring out which tiles belong to which sprites afterwards.

Another approach I sometimes use is to include an empty area below a given sprite image, and then make sure to paint with all the colors from the palette in this area. When BMP2Tile processes this, the palette is preserved, and I can include every tile but the last as an asset.

I guess what I want is a feature in BMP2Tile that allows me to keep the palette intact (I guess the palette is in the BMP source image?). But chances are that this request stems from a sub-optimal workflow, so here goes: How do you guys handle the same palette across multiple images, in a way that lets you easily convert them to tiles separately?

Argh man, that was a wall of text. Sorry.
  View user's profile Send private message Visit poster's website
  • Joined: 17 Sep 2013
  • Posts: 128
  • Location: Gravataí, RS, Brazil
Reply with quote
Post Posted: Mon Apr 11, 2016 11:49 am
I built a tool that I use to reorder entries on the palette, since palettes have always 16 entries, even when all of then are not used I'm pretty sure that will do for you, it's not polish at all, but it works, if you want, send me a PM.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Mon Apr 11, 2016 12:29 pm
hang-on wrote
I guess what I want is a feature in BMP2Tile that allows me to keep the palette intact.


Yes, it's a much needed feature, I guess you should request it. (I usually have the sprite on a single sheet to avoid any problem...)
  View user's profile Send private message Visit poster's website
  • Joined: 01 Feb 2014
  • Posts: 878
Reply with quote
Post Posted: Mon Apr 11, 2016 4:10 pm
To be fair, the problem is only partly BMP2Tile's fault.

I use ProMotion to synchronize the palette across my various image files, and BMP2Tile converts it correctly if the image I use to export the palette has at least 1 pixel of colour #15. BMP2Tile keeps all palette entries before that intact. On the other hand, annoyingly it cuts off any unused colours whose numbers are higher than the highest one that's actually used.

So if you get incomplete palettes with lower entries missing it's likely the unused colours got cut off by your other graphic programs beforehand.
  View user's profile Send private message
  • Joined: 23 Mar 2013
  • Posts: 611
  • Location: Copenhagen, Denmark
Reply with quote
Post Posted: Mon Apr 11, 2016 5:34 pm
Last edited by hang-on on Mon Apr 11, 2016 8:20 pm; edited 1 time in total
Thanks for the replies! Much appreciated!

@gvx32 - I'll PM you in a moment for that tool. Thats very kind of you - thanks!

@sverx - I tend to use the single sheet approach as well. I guess you are right about the feature request, then. Yeah, community: I hereby request a "preserve full palette" feature in BMP2Tile (or PNG2Tile). Haha - does it work this way? :) ... meanwhile, see below >>

@Kagesan: I did some experimentation after I read your post, and .. tadaa... When I process an image and make sure to include the last color in the palette somewhere, I get the full palette when exporting via BMP2Tile! Wow. That solves my issue for now. Thanks!


EDIT: My new standard setup: First color (color 0) is the classic purple background color for transparency. Last color (color 15) is the outline color (usually black). That way, I get all the colors in between when I save as .bmp and dump on BMP2Tile Hooray! :)

EDIT2: Deleted my false claim about differences with regards to file format.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Mon Apr 11, 2016 7:52 pm
hang-on wrote
I did some experimentation after I read your post, and .. tadaa... When I process a .png, BMP2Tile makes a palette for me with the used colors only. When I process a .gif or a .bmp, and make sure to include just the last color in the palette somewhere, I get the full palette!


Weird! I really didn't expect a different outcome based on image format... are you sure it doesn't depend on number of colors (of the image format)? I'm always using 16-colors PNG...
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14745
  • Location: London
Reply with quote
Post Posted: Mon Apr 11, 2016 8:06 pm
hang-on, the palette in the PNG is not the same as the other two files.

Personally, I tend to use "sprite sheets" (including backgrounds), but not always. I usually use PNGs, and have a master .pal file I can force onto them if I want to change the palette order.
  View user's profile Send private message Visit poster's website
  • Joined: 23 Mar 2013
  • Posts: 611
  • Location: Copenhagen, Denmark
Reply with quote
Post Posted: Mon Apr 11, 2016 8:17 pm
Sorry for the confusion, guys. I messed up with the palette - I even double checked it before I posted. So no difference between different formats, but Kagesan's tip about making sure you use the last color still stands.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Mon Apr 11, 2016 8:51 pm
according to BMP2Tile source code, it's exactly as Kagesan said. I filed an enhancement request at Maxim's github repo a few minutes ago.
  View user's profile Send private message Visit poster's website
  • Joined: 09 Apr 2013
  • Posts: 106
  • Location: Sydney Australia
Reply with quote
Post Posted: Tue Apr 12, 2016 11:40 am
I use Gimp and grafx2 for my palette manipulation. Gimp allows you to index an image using the palette from another image. :)

I also use Grafx2 to reduce the palette and to move colour entries around.

If there's anything you want me to add to PNG2Tile just let me know. I'm pretty busy with Monkey Lad at the moment though ;-)
  View user's profile Send private message
  • Joined: 04 Jul 2010
  • Posts: 542
  • Location: Angers, France
Reply with quote
Post Posted: Tue Apr 12, 2016 1:57 pm
On my side, i'm using Photoshop => export to web feature (with .act palette)
+ a homemade tool to import/export/modify palettes - .inc (wladx) and .act (photoshop)
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14745
  • Location: London
Reply with quote
Post Posted: Tue Apr 12, 2016 7:06 pm
hang-on wrote
Yeah, community: I hereby request a "preserve full palette" feature in BMP2Tile (or PNG2Tile). Haha - does it work this way? :)


https://github.com/maxim-zhao/bmp2tile/releases/tag/v0.42

It's a bit weird - it always emits 16 colours when you check the box, but the image might not even have 16 colours, so I pad them with black. I could maybe more clever and emit as many as are defined in the image, but this is probably good enough for what you want to do.
  View user's profile Send private message Visit poster's website
  • Joined: 23 Mar 2013
  • Posts: 611
  • Location: Copenhagen, Denmark
Reply with quote
Post Posted: Tue Apr 12, 2016 7:14 pm
Yeah - thanks Maxim. Just tested the new version on the Gargoyle sprites I attached to my post in the PNG2Tile thread, and the new "Always emit 16 colors" option is exactly that feature I requested just yesterday. Super!! Thanks a lot.
  View user's profile Send private message Visit poster's website
  • Joined: 07 Oct 2015
  • Posts: 114
Reply with quote
Post Posted: Fri Apr 15, 2016 9:11 pm
In my converters, when the target system uses a palette, the program reads the desired palette colours and their order from a 16x1 pixels png file. Converted data always uses the provided palette. That way I can have total control on which colours are output.
  View user's profile Send private message
  • Joined: 01 Jan 2005
  • Posts: 360
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Sun Apr 17, 2016 12:51 pm
I made a script for Personal Paint that generates remapped sprite sheets and a commented text file with constants for each file. It just lacks a line to write out the remapped file for each single tile/sprite.
https://github.com/idrougge/BatchRemapBrushes
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!