It is currently Fri Nov 17, 2017 10:47 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Fri Jun 20, 2014 11:20 pm 
Offline
User avatar

Joined: Fri Jun 06, 2014 12:22 am
Posts: 16
Hi guys! I'm writing a map editor,
and now i'm stuck on how to convert
RGB to nes palette color.
thanks in advance!


Top
 Profile  
 
PostPosted: Fri Jun 20, 2014 11:45 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10112
Location: Rio de Janeiro - Brazil
Why do you need to perform this conversion? Are you taking graphics using arbitrary palettes? Are the palettes expected to resemble the actual NES colors? You can try to do the conversion based on what you think the NES palette looks like, but when users have the freedom to use whatever palettes they want you have to ask them to provide the palettes they used so you can convert the graphics properly.


Top
 Profile  
 
PostPosted: Sat Jun 21, 2014 4:29 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19219
Location: NE Indiana, USA (NTSC)
If you understand Python, there is a program that does this in the source code of the Action 53 menu. It converts 64x56 pixel screenshots to NES tiles, guessing a 4-color palette for each.


Top
 Profile  
 
PostPosted: Sat Jun 21, 2014 12:14 pm 
Offline

Joined: Mon Sep 27, 2004 2:57 pm
Posts: 1248
It's a million times better to design the graphics around the palette, instead of doing a lossy RGB->Palette conversion.

If you have to though, you can grab an NES palette, and convert to it by taking the input color and finding the closest match in the NES palette (i.e., which color has the closest R, G, and B values). Keep in mind that most emulators use their own palette, and most people use their own palette, so in reality, this is a huge crapshoot.


Top
 Profile  
 
PostPosted: Sat Jun 21, 2014 2:02 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2352
Convert it from RGB to YUV. Convert UV to phase and amplitude. Quantize the colors to 4 luma levels, 12 phases and 2 amplitudes.


Top
 Profile  
 
PostPosted: Sat Jun 21, 2014 8:36 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19219
Location: NE Indiana, USA (NTSC)
Or just compare to all colors in the palette using a metric like ((r1-r2)^2*3 + (g1-g2)^2*6 + (b1-b2)^2). You're going to have to do this comparing for each pixel even if the user provides an 8- or 32-digit list of palette indices.


Top
 Profile  
 
PostPosted: Sat Jun 21, 2014 9:46 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10112
Location: Rio de Janeiro - Brazil
Yes, there's no way around the color detection, but the accuracy of this detection might be poor if the program and the artist use very different palettes. I think you should have a default palette, but allow users to provide their own (kinda like emulators do) if they are no satisfied with the default conversion.


Top
 Profile  
 
PostPosted: Sat Jun 21, 2014 10:04 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19219
Location: NE Indiana, USA (NTSC)
That or add a feature to the conversion tool to export the 64-color palette it uses as a PNG, so that the artist can tune the graphic to the palette. That's the approach I'm using.


Top
 Profile  
 
PostPosted: Sat Jun 21, 2014 10:16 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10112
Location: Rio de Janeiro - Brazil
That could be an option as well, but people are stubborn. There will always be someone that will not let go of their own palette.


Top
 Profile  
 
PostPosted: Sat Jun 21, 2014 10:26 pm 
Offline

Joined: Mon Sep 27, 2004 2:57 pm
Posts: 1248
tokumaru wrote:
That could be an option as well, but people are stubborn. There will always be someone that will not let go of their own palette.

Me for example. :D

That's why I said it's better to design the graphics around the palette. It'll look subtly different from person to person, but at least red will be red and blue will be blue.

You know, this is starting to sound an awful lot like the lament of television graphic designers in the 80s and 90s.


Top
 Profile  
 
PostPosted: Tue Jul 01, 2014 11:57 am 
Offline

Joined: Tue Jun 28, 2011 2:39 pm
Posts: 152
Allowing custom palettes has this advantage that editor won't be tied into nes. It could be used for GB/MasterSystem/Other 8bit systems, heck it could be used as general map editor if someone makes game with retro graphics.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: FrankenGraphics and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group