Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Great! One *tiny* request

A topic by zweifuss created Jul 02, 2021 Views: 303 Replies: 14
Viewing posts 1 to 8

I love this, I was scouring the 'net for a few days until I found something I wanted. It's sooooooo close to what I want! I am just a hobbiest who enjoys browsing through sprite sheets. Would it be possible to do a '1:1 swap' button? In other words: 

  1. Load a sprite sheet PNG with an indexed colour palette with a grey-scale gradient
  2. Load a map palette, it also has 16 colours. 
  3. Click to map those 16 colours 1:1 from the map palette

Right now I can make it work, but it's just so tedious to click source colour, then click map colour, for 16 colours (32 clicks in total), when I know it's possible you could make it all happen with one click? This would be similar to the 'AUTO MAP' button, but instead of doing CMI match it would just map the pallet to the index. I've enclosed an image to hopefully show you what I mean. I got the result I wanted but it would have been more convenient to just have a button that does it right away, as I already have 16 different palette files ready to go.

Again, thank you SO MUCH for this amazing tool.

Developer

Thanks so much for your kind words!  
So glad to hear you like the tool and find it useful.  I've told this story a few times, but when I was first making the tool, I was kicking myself the whole time, thinking 'why are you reinventing the wheel, there has got to be something out there that does this already.'   But I searched and searched and couldn't find anything, so I'm glad to hear you find the tool useful (perhaps showing that I was not crazy for writing it) and glad to hear it turned up when you searched for something (because I was in that spot myself not long ago ;)  
BTW Since I wrote this tool, two other intrepid programmers over on OpenGameArt have come up with their own takes on the idea.  You can find the results here:

https://repixel.app/

and here

https://williamthompsonj.github.io/Color-Palette-Swapper/

and a big thread discussing the whole topic here:

https://opengameart.org/forumtopic/tool-for-palette-swappingchanging

Finally, thanks for the feature suggestion!   And for the example picture, it really helps me understand what you're after.   I'll look into implementing this.   Internally, the program doesn't use Index mode at all, everything is full fat 24-bit RGB pixels, so there might be some challenges, but it does load indexed images and knows how to inspect the palette entries for an index image, so I'm sure I can figure out a way to get it working for you.

It is funny to say, because it's definitely not digging ditches, but I know what you mean about 32 clicks feeling like a lot of work!   :)

(1 edit)

Wow thanks for the reply, wasn't expecting one TBH! Thank you for all the leads, I think I may be able to use some of them to my exact needs. And I'd like to thank you and other Indy developers out there that keep the pixel sprite dream alive, I hope it never dies out! I fell in love with it back in the 90s when playing platformers on SNES and PC and I will always look back fondly at those games, but at the same time it's amazing to see new games being made with pixel-based sprites. 

So far I've tried the re-pixel app which is neat, and Grafx2 to varying degrees of success, but I'd still like to see it in your program if you can make it work!

The real issue I have with the programs you mentioned, is that they are designed to do automatic colour matching, so they will find the closest colours in the loaded palette instead of swapping the indexed colours of the original with the new one. re-pixel app will do index swapping, but only with the palettes preloaded into the GUI, not the one you load. I think I may have to set up an account on that forum to explain to the other developers what I'm looking for. Auto-colour matching is great for when you want a tighter palette for your sprite, or want to change the mood in a certain scene, but for me I just want to see sprites with different pre-defined palettes at a quick glance.

Thanks again

Developer

> I'd like to thank you and other Indy developers out there that keep the pixel sprite dream alive, I hope it never dies out!

Your welcome and I couldn't agree more!  :)


> it's amazing to see new games being made with pixel-based sprites.

Completely agree!  What's equally exciting for me to see as a creator is that there's such a strong audience out there for pixel art creations!   It's great to see that gamers are still willing to accept and play pixel art games in this day of unbelievable 3D graphics tech.  :)


> I'd still like to see it in your program if you can make it work!

Ask and ye shall receive!   :)

https://withthelove.itch.io/pixelpalettetool/devlog/272101/pixel-palette-tool-v1...

Let me know if that does the trick for you.  I don't work a ton with indexed images myself so I might need you to loan me an image or two for testing if it doesn't work the way you're expecting.  

Wow nice work! This does *exactly* what I wanted it to do! Thank you so much. Here is what I've discovered so far:

  • There is the odd crash sometimes. I can upload the files that crash it if you'd like. It might have something to do with if I make one of the colours have a transparency flag.
  • It doesn't seem to load the PNGs I have with the correct palette order. I still have to re-arrange the order. I sometimes use old programs like PaintshopPro to save the PNG files, and in that program they are most certainly in the right order. So It'd be cool to have an 'arrange palette by hue' button or something if the index doesn't get loaded right
  • When saving the PNG file, the colours don't seem to be indexed correctly either (saved with PixelPaletteTool, opened in GIMP)
  • When an image does load with the correct index, there are weird artifacts in the mapped image.. like it shows a random colour strip under the image, I don't know what's up. 

Other than that, it is really on its way there! Holy Cow I did not expect a developer to be so quick on the draw to add a request.. so here's another LOL

What if... 

  1. I load a 16-colour indexed image, grayscale from black (0 0 0) to white (255 255 255). The palette is arranged correctly in a nice gradient.
  2. I load a palette with 256 colours.
  3. I shift-click on the 1:1 icon - great, it replaces the grayscale with my palette (the first 16 colours). 
  4. Now here is where the new feature comes in: "SHIFT BY INDEX COUNT" or something to that effect. The program will now grab the next 16 colours in the strip and replace the index with those colours. So if my original PNG has 64 colours, if I'd load up a 256 colour palette it would shift by 64 so I could try out 4 different patterns, etc.

It's not *quite* colour-cycling per se, it's something a bit different.

Anyway, *so happy* again you're doing this, I feel it's already at a place where I can play around with it and see what it can do. 

Long story short - I used to run this Street Fighter III - Third Strike animation appreciating site, and I played around a lot with palettes, swapping them in my animated GIFs and everything, but then family happened and I couldn't dedicate time anymore to it. This whole thing is getting me excited again for these sprites, and I'm really looking forward to see what you can do.

Thanks again!

Developer


> There is the odd crash sometimes. I can upload the files that crash it if you'd like.

Oh no!   Sorry to hear this!   Yes, if you could post the file(s) that would be a big help!

> It might have something to do with if I make one of the colours have a transparency flag.

One thing to note is that program only deals in binary transparency (on/off).   Specifically, it maps ignores any color with an alpha value less than 255, and maps any pixel with an alpha value less than 255 to the color (0,0,0,0) (RGBA).   This is a deliberate design choice on my part to keep things simple and because the use-case for the program is simple pixel art with binary transparency.   All the same, the program shouldn't crash if you load an image with other alpha values so I'll definitely look into it.


> It doesn't seem to load the PNGs I have with the correct palette order...When saving the PNG file, the colours don't seem to be indexed correctly either

Oh dear, sorry to hear this.  I was worried about something like this because I only tested it with a few images from GIMP.  If you could post an image that doesn't load in the correct order along with a pic of what the correct order should be that would be awesome!

> When an image does load with the correct index, there are weird artifacts in the mapped image.. like it shows a random colour strip under the image, I don't know what's up.

Can you also send an image file that has this issue?



> SHIFT BY INDEX COUNT

If I understand you correctly, what you are asking for is for the mapper to create multiple maps for you by progressing through the palette.

So...

Map 1 maps Image Colours 1-16 to Palette Colours 1-6

Map 2 maps Image Colours 1-16 to Palette Colours 17-32

Map 3 maps Image Colours 1-16 to Palette Colours 33-48

etc. etc.

Is that right?

you'd press the button once and it would spin out all these maps for you.

(2 edits)

EDIT: Upon further inspection it seems the garbled images with the small pixels beneath them seem to be if the dimensions of the picture are too small. If I use an image file with wider dimensions the problem goes away. Looks like the program crashes if the palette saved is only 16 colours, when it's 256 colours it's fine. That's my observations so far...

Original reply below:

Ok I'd like to help get to the bottom of this for you so I'm here to help.

Here is a file that crashed it.

Here is a file that should have the colours in the correct order but doesn't. This one I set the first index value to be a transparency.

Now here is the same image if I don't set the transparency. This one loads the colours in the right order, but it has a funny colour strip below the mapped image (the right panel), and when I try to apply a map it gives funny garbled colours:

So I was actually able to get the program to work properly with the images one time, what I did was I loaded the original spritesheet and decreased the colour count to 256 instead of 16... Then I got it to work. Here is the file that actually works as intended. 

So if I load this palette strip:  I get this result:

Lastly, for your shift by index count, that is exactly what I want, you explained it the perfect way. "

Map 1 maps Image Colours 1-16 to Palette Colours 1-16

Map 2 maps Image Colours 1-16 to Palette Colours 17-32

Map 3 maps Image Colours 1-16 to Palette Colours 33-48

etc. etc."

Awesome!

Well thanks for reading my long-winded post, hopefully it helps you out!

Developer

> Upon further inspection it seems the garbled images with the small pixels beneath them seem to be if the dimensions of the picture are too small.

The program uses OpenGL for display and a rule of thumb OpenGL likes even (mulitple of 2 or better yet power of 2) image sizes.  So it's possible the garbled pixels along the edge are just display issues caused by OpenGL quietly stretching the image to the next power of 2 or whatever behind the scenes.

I'll play around some with the image you provided and see if I can confirm that that's what's going on.


> Looks like the program crashes if the palette saved is only 16 colours, when it's 256 colours it's fine.

You hit the nail on the head.  Just dug through the code and in fact there was a crash bug pulling in images with a 4bit (16 color) index palette.

Pretty sure I've got that fixed now.  Going to keep looking on the other problems and hope to post a new build for you shortly.

> re: the out of order palettes:  

quick update after my first pass at figuring it out.   It looks like the program is reading those images in as 32bit RGBA images instead of indexed images.   Loading them in GIMP I can confirm that they should be indexed, so not sure what's going on.  

The program uses the standard C# image loader so something in that loader must be quietly reformatting the image.  Hopefully I can figure out a way to avoid that behavior...



Thanks so much for all the sample pictures!!   It really helps to have the exact data that's triggering the issue to test with.  Saves a lot of guessing.  :)

Developer

ok, I take that back about the garbled pixels.  It appears to be something more, looking into it....  

Thanks for looking into it. Since I've created the first post I've played around a lot with Grafx2, and it another program called mtpaint which have some very neat palette functions, but I'll say it again, your program once its bugs are ironed out would still be my go-to for this kind of thing.

Developer

haha, no worries if you find a better tool, just be sure to let me know about it so I can use it too!  :)

I've actually used both mtpaint and Grafx2 and like them both!   Grafx2 in particular is designed with indexed palettes in mind, so it does a much better job with them then GIMP imho.

btw, found the garbled pixels bug.  It did have something to do with OpenGL and 'odd' image sizes.  Although, as it turns out, not 'odd' as is in 'not divisible by 2' but 'odd' as in 'doesn't result in pixel data that perfectly aligns to 4 byte chunks'.   I've got a fix for it, hoping to look more into the 'palette loading out of order' bug and then roll out a bug fixed build soon.

thanks again for your patience and providing demonstration files!

Developer

Ok, v1.92 is released! 

https://withthelove.itch.io/pixelpalettetool/devlog/275924/pixel-palette-tool-v1...

It should address the garbled pixels issue and the crash bug when loading 16 color indexed palettes.

For the 'out of order palette' issue, it looks like this is an issue with the C# Bitmap API.

https://stackoverflow.com/questions/44835726/c-sharp-loading-an-indexed-color-im...

tldr; any indexed PNG with transparency is converted to a full fat RGBA 32bpp image by the C# Bitmap API which Pixel Palette Tool uses to load images.   So by the time the tool sees the image data, it has already been converted to an RGBA image and the index palette has been tossed.  Since there's no palette attached to the image at this point, the tool goes about it's normal process of extracting the palette from the image by scanning the pixels left to right, top to bottom.   The result is that it gets the correct palette but not in the correct order.
As this is a problem in the C# image loading API, the only real solution would be for me to find another PNG loader or write my own.  :(
The only silver lining is that the C# image API does seem to process indexed GIF images with alpha transparency just fine.  So the workaround for now is to use GIF images if you want to load indexed palettes with transparency.

Thanks again for all your feedback and help ferreting out these bugs!  

> SHIFT BY INDEX COUNT

Will work on this next.  It shouldn't be too hard, the main challenge (as with so many features) is how to make it intuitive in the UI.

Nice! Now it's running really nicely... exactly what I needed. Check out this screenshot... looking forward to the new features!

Developer

Awesome!!  So glad you find the tool useful!

btw

if you hadn't noticed before, you can hit the buttons that says 'SHOW FEWER MAPS' to reduce the number of maps the tool displays at one time.   I think the default is to show up to 5 but I actually typically work with just 1 displayed at once.  Well if you already figured that out, no worries, and if you didn't no worries, the text on those buttons is impossibly small.  :)

Yup I figured that out too, it's a great tool, I hope other people find out about it. Can't wait to see that new feature in there (someday, no hurry lol). At its current state it's already heaps better than when I first installed it!