This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Tool for converting existing picture -> chr nes

Tool for converting existing picture -> chr nes
by on (#220805)
I'm sure it was discussed before but I cannot find the appropriate threads on the subject.

I'm looking for a tool that would convert an existing image so it could be used on the nes. I just want to convert some logo that are already using a low count color to something that would be close to what the nes would use.

I found the tool by thefox which convert an image to a nes file. It looks exactly how I would like it to be (color and result) but since I need the chr/pal only, I cannot really use it, unfortuately. And from the look of it, it does a lot of processing to make it look the way it is (which is impressive for an automated tool by the way!).

I will continue to search on the forum for the time being.

Thank you in advance for any information on the subject.
Re: Tool for converting existing picture -> chr nes
by on (#220806)
You could probably use thefox's tool inside a batch file that after it's done splits the rom into the chr part that you want.
Re: Tool for converting existing picture -> chr nes
by on (#220808)
Use Kasumi's I-CHR. If you provide it with a palette map when importing, you're likely to get perfect results.

You can also use NESST with some conditioning, usually with a trial and error phase, but it tends to mess up the bit planes and palettes more often than not. So I-CHR is way better for this task.
Re: Tool for converting existing picture -> chr nes
by on (#220812)

Since the test picture was more complicated than I thought, it is using (my guess) many banks to simulate all the details of the image with all the colors (I think sprite are used too). So the size of chr data is too big in that case. Still, it's quite impresive how close to the original it looked.


nesst crashed on the bmp and as for i-chr, I still don't know how to use it so I guess I will need to read the manual ^^;; Right now I'm testing with some existing company logo like, for example, the initCreate one used in "bloodstained, curse of the moon" and the best result is with thefox tool. So I guess if the logo, even thought simple, contains too many color or details, I will need to reduce the color count more if I want i-chr to work better (I'm guessing).

I'm not really an artist so for now my approach is maybe not appropriate. Still, a lot of fun to test many pictures to see how well they get converted. My test will be useful once I have something more concrete to use. For now I'm mostly getting back in nesdev, after 9 years of hiatus. C with asm is quite interesting, I like it.
Re: Tool for converting existing picture -> chr nes
by on (#220819)
I wrote a tool called "" to manipulate NES background images, converting them among a PNG (or other lossless image formats compatible with Pillow, the fork of Python Imaging Library), an 8K .sav file that contains pattern table and nametable data, and separate .chr and .nam files. It was originally to get files in and out of my graphics editor that runs on an NES, but I ended up using that converter far more than the editor.

Drawback: You have to specify a 32-nibble palette string.
Re: Tool for converting existing picture -> chr nes
by on (#220820)
nesst crashed on the bmp

It should be 128x128 (or maybe 256x240 ?) BMP indexed-color with 16 colors, And frequently it doesn't import the palette correctly.

I prefer to reduce to B+W, then index to 4 colors, then back to RBG, then index to 16 colors, then export BMP.

Then manually choose the 4 colors in NESST.

Another easy method. In GIMP / Photoshop, reduce image to 128x128, then reduce to indexed 4 colors (any), then select all, copy. Open YY-CHR, paste.
Re: Tool for converting existing picture -> chr nes
by on (#220822)
Is the BMP compressed? Does the tool support BMP compression? If not, what will it do if handed a BMP with compression? Etc. etc. etc...
Re: Tool for converting existing picture -> chr nes
by on (#220823)
To use I-CHR save your image as a PNG, instead of a BMP. Then just open the png file (with ctrl+o) after the program is already running, or drag the png file onto the exe. It'll create a folder for you with the files you need or display the reasons why it couldn't with marked pixels. (Toggle viewing error pixels with spacebar.) Assuming there were errors, you can fix them in the image editor of your choice, resave the file and press 'R' in I-CHR to try to export again.

It has two known bugs that won't affect most people.

1. Any PNGs with semi transparent pixels will have an odd result.
2. Filenames with a number >= INT_MAX or < INT_MIN in them won't load.

Beyond that it should load any PNG regardless of if it's indexed or how it's indexed, or the size of the image or anything else. I-CHR will crop image widths or heights to the nearest multiple of 16, though. (NES Screen Tool requiring data massaging beforehand is exactly why I wrote I-CHR. Well, that and NES Screen Tool lacks animation support!)

But it only works on things that are already NES ready. I've considered adding color quantizing to it, but since Aseprite already does that quite well, (Sprite, Color Mode, RGB Color. Create palette from current sprite, input a number of colors. Sprite, Color Mode, Indexed) it's pretty low on the list. Even then, an 8 color image doesn't guarantee < 4 colors in a 16x16 region so quantization alone will really only help the sprite import side of things. thefox's tool is indeed really impressive. (The non public version of I-CHR has an option to automatically turn error areas into a sprite overlay, but I feel like I'll never get that version of the program to a state that I'm comfortable releasing.)

I-CHR does mark error areas to help you make fixes yourself, but it's not very convenient in the public version because that one doesn't having zooming/panning.

Edit: If thefox's tool gives you VISUAL output you like, but not the FILES you want. Use thefox's tool to make a ROM, then import a PNG screenshot of that ROM in I-CHR. (This topic did make me think of an algorithm that might work on arbitrarily colored images but at the rate I'm going I'll never even finish cleaning up the UX for the sprite import stuff...)

Edit2: Nevermind, I guess. I just read the post that says it might be using splits to use more than 256 tiles.
Re: Tool for converting existing picture -> chr nes
by on (#220832)

I will test it once I have a chance. Since it's in python, maybe it could be updated to read a palette file, I guess? I could try to add it, once I see what I can do with it.


I have been naively experimenting with files that have not been "massaged" (is it appropriate to use that in English regarding updating a file? ^^;;) with lower color count to see what the tools can do. Since I do not know them yet, I just wanted to see the result from non optimized file. I think I now know that some work is required :)


Good question. I just converted the png to bmp with gimp and nesten didn't mention anything about the format except for bmp so I didn't check that far. It could be either that (compression) or the color count was too high. Will check the format.


My original test file was a png and only used that with your tool. It did convert to some degree but there was some error (I think, from the name of the files in the resulting folder) and didn't know what to do with them yet. Like mentioned above, I naively tested non optimized files so my guess is the file would have never worked properly in the first place. I did reduce to 16 colors but I think the picture I tested, even though the color count was lower, was maybe too complicated for automation. I wanted to know how much could be done since I will need later to convert some image. My test samples is giving me a good idea of what can be done (i.e. some manual work is required with sprites etc if you want to have higher color count).

I will include the test image, since it will give a better idea of how much not optimized it was. I took a screenshot of a logo of a recent game (bloodstained), reduced the size to 256x240 and tested it, as-is, in a few tools. thefox tool gave 100% the same result but the wizardly done with the tool makes it hard to re-use later in an actual project.

Now I know that some work with be required by an artist (which I'm not) if some existing logo are to be imported.
Re: Tool for converting existing picture -> chr nes
by on (#220842)
That image has 1621 colors! I-CHR's only for stuff that's already not breaking NES restrictions. I guess I misunderstood when you said already low color like the NES.

Here's an "automatic" conversion of the logo (full disclosure: not your specific image of the logo) from the non public I-CHR using the power of sprite overlays:
INTILOGO.nes [40.02 KiB]
Downloaded 85 times

All I did beforehand was quantize it to 10 colors and resize it (with nearest neighbor to have less antialiasing) using Aseprite. There may be gaps because of 8 sprites per scanline. (The ROM doesn't have flickering built in yet.) Some things that are the same color in the source image end up as different colors when used in the sprite vs the background layer. I know why, but it's actually not super simple to fix. (That's actually one of many things this test found, so thanks for that!)

edit: It works by pulling pixels that would cause background errors onto a new layer until there are no errors left. That method will obviously create hundreds of sprites depending on how spaced the colors are, it's not a magic bullet.

edit2: The difference between this tool and thefox's is that this wants to be pixel lossless. (It wants to display the exact same image it's given, just with the NES palette.) For this reason I get the impression it will fail at most of what you're trying, but if you want to try this version PM me. It doesn't export the sprite CHR or the sprite positions, but that's easy enough to rip from the ROM/OAM memory in NES. There's no scanline magic, but know there totally are bugs and this isn't the part of the program I'm focusing on right now. (It may not even make the next release.)

edit2: I tried your actual image (rather than the logo I resized myself) and it wasn't feasible even at 8 colors. Here's the 7 color version:
INTILOGO7.nes [40.02 KiB]
Downloaded 74 times

It still needs 73 sprites, but the ones that got dropped don't seem to have much effect. The colors aren't great either, but part of that is how Aseprite quantized it.
Re: Tool for converting existing picture -> chr nes
by on (#220848)

The image I provided was the screenshot from the game, resized only without any color indexing. That was quite naive to expect it would work but the goal was to research was is possible and now I have a better idea about it (I did test it with 256 and 16 color too). thefox tool creates the most accurate color but is not very practical to use in an actual project because of the data is big (maybe there are way to optimize with reduced image color, who knows, more testing is required since I do not know the tool yet).

The example you made with your own image is quite good, it's very close to the original :) So the results of those tests is to use existing image that are not nes specific will require a lot of processing. Your tool will be quite useful with a properly optimized image.

Thanks for the testing and feedback, I really appreciate it!
Re: Tool for converting existing picture -> chr nes
by on (#220852)
Here's another try that uses all background.

First, I replaced the text color with savtool's idea of what color $12 is (#4051d0). Then I aligned the logo better with the attribute grid by moving it up 2 pixels and to the left 3 pixels. (On the NES, scrolling can compensate for this move.)
inticreates1.png [ 7.78 KiB | Viewed 1597 times ]

I iterated on the palette until I found something that closely represented the gradient of the logo with few colors. (To show what a conversion looks like without saving it, you can use --show instead of an output filename.) It turned out to need only 3 of the 4 subpalettes to look reasonable.
../tools/ inticreates1.png --palette 2028122B201612142016122720242424 --show
../tools/ inticreates1.png --palette 2028122B201612142016122720242424 inticreates1-out.png

Then I edited inticreates1-out.png to add dithering in the gradients, forming inticreates2.png
inticreates2.png [ 1.85 KiB | Viewed 1597 times ]

Once an image obeys PPU background limits, it can be converted to a .sav for display in the editor on an authentic NES and PowerPak.
../tools/ inticreates2.png --palette 2028122B201612142016122720242424 inticreates2.sav

From there, the .chr and .nam can be extracted for compression and use in an original NES program.
../tools/ inticreates2.sav inticreates.nam
../tools/ inticreates2.sav inticreates.chr
Re: Tool for converting existing picture -> chr nes
by on (#220853)

Very nice result! So from what I understand you where able to make it works without sprites, right? If that so then it's a good balance between compromise and functionality. The only thing is I need to learn more about is how to find where the issues are so I can optimize the picture the way you did. I don't have that experience yet so I think it's time to get my hands dirty. Thanks again!

So many great tools and results, I'm quite happy to have asked about it. Can't wait to use them on my current project.
Re: Tool for converting existing picture -> chr nes
by on (#220855)
Kasumi wrote:
Edit2: Nevermind, I guess. I just read the post that says it might be using splits to use more than 256 tiles.

Yeah it doesn't optimize the tile count at all, its output is essentially a bitmap. Moreover, it uses 8x16 attribute areas by switching nametables every 8 scanlines. It's not really designed for use cases like this, although it can be used to get a general idea about what is possible.
Re: Tool for converting existing picture -> chr nes
by on (#221427)
This is my converter of images to NES based in gallleryNES of no-carrie

It is something that wanted to arm does a lot and now did me a time
Re: Tool for converting existing picture -> chr nes
by on (#221461)

This is an interesting concept for images with high details but in my case I'm trying to make it looks at close as possible as the original so I'm not sure for a logo how much impact it would have.

I will give it a try once I have some time to experiment. Thanks!