Saturday 2 May 2020

Chapter 13 // Exercise 7 - Principles & Practice Using C++

In this exercise I am using Visual Studio 2017 and the graphics files found here:
https://github.com/l-paz91/principles-practice/tree/master/Graphics%20Files

Chapter 13 // Exercise 7

Make and RGB colour chart (e.g., search the web for "RGB colour chart").

Github: https://github.com/l-paz91/principles-practice/blob/master/Chapter%2013/Exercise%207


This was perhaps one of my favourite exercises so far as it was something I actually wanted to know how to do but always got overwhelmed when I tried to when picking a language/api.




I currently have a program that converts 24 bit bitmap images to SNES format however, it's only a command window program at the moment. One of the upgrades I wanted to add was the ability to change your colour palettes by selecting from a colour chart. I was going to do a C# winforms program however, I feel confident that I could get the program done now using FLTK and C++ which is great because I hate C#.

As a little bonus I decided to write a program that draws the full colour palette that the SNES can use. The SNES uses 15-bit GBR. It's not 16-bit RGB because Nintendo*. This means there is 32,768 colours that the SNES can display (not all at once though). I think this is known as 'high-color'. Either way, here they are:



This took me several days to wrap my brain around; colour is hard. It took me a while to figure out the name of what I trying to do. Apparently I wanted to make a 7 colour gradient heatmap. I eventually settled on this wiki here, that shows how to create a colour gradient class:
http://www.andrewnoske.com/wiki/Code_-_heatmaps_and_color_gradients

I changed a few things and added the ability to create different gradients based on how many colours you want. I also made options to create 15 bit gradients but they look pretty much the same. Instead of uploading that here I'm going to clean it up a bit and do a tutorial on how to add a Colour Gradient class to FLTK using Bjarne's suite of functions. I wanted to add black and white to the gradient map but I'm unsure how to do that just yet.

This link has nothing to do with anything really but I'm leaving it here because I know I'll forget where I've bookmarked it:
https://docs.microsoft.com/en-us/windows/win32/directshow/working-with-16-bit-rgb

*if you're interested it's because 65816 only accepts bytes that are 8 or 16 bit in length and 8 or 16 cannot be evenly divided by 3. Therefore, the high byte is padded with an extra bit. This extra bit is always set to 0 and the SNES expects it to be 0. Some people assume this bit is used for alpha (aka transparency) however it is a single bit; either on or off and therefore can't convey how much transparency is needed, so it is simply just for padding. 

No comments:

Post a Comment