I’m in the process of building an interactive beer pong table for one of my mates. Keep your eyes out for the blog posts on the table build. A major part of this build is a 50×18 RGB LED matrix. I’m using ws2812b LED strips and controlling them with an Arduino. I’m powering them with my Test Bench Power Supply for now. I wanted to use this array to display some images. There was no way I was going to convert them by hand so I made a program to do it, the Image to RGB Array converter. This program converts an image (.bmp, .gif, .exif, .jpg, .png, .tiff) to a text file. This text file contains an array of three-byte hexadecimal values, which can be pasted into an Arduino program.
How It Works
The program reads in an image file. It then scales it to the resolution specified in the rows and columns boxes (for my example 50 columns and 18 rows). Once scaled it goes through the image one pixel at a time and converting the Red, Green and Blue components to a hexadecimal value. The RGB values are then combined in to one large hexadecimal value and written to a file. For example white becomes 0xFFFFFF, and black is 0x000000, red is 0xFF0000, green 0x00FF00 etc.
Source Code
I have uploaded the source code and a .exe that can be downloaded below. It’s written in C# using Visual Studio Community (download it here), so I have uploaded the whole solution. They are both zip files, but uploaded as pdfs, so you will have to change the extension once you download them. GraphicsConvert is the exe only. GraphicsConvertSolution has the source code and Visual Studio files.
Example
Below is a screen shot of the program. It’s pretty basic, enter the number of columns and rows, pick your files and hit convert.

Below is an image of what the Australian flag looks like on the LED matrix (well half of it anyway, I haven’t setup the other half yet) and the corresponding text file.

0xED5471, 0xF28A9D, 0xFAE1E6, 0xBEC7D9, 0x6377A3, 0x102E72, 0x012169, 0x012169, 0x012169, 0x012169, 0x95A2C0, 0xEB4060, 0xE4002B, 0xEB4060, 0x95A2C0, 0x012169, 0x012169, 0x012169, 0x012169, 0x102E72, 0x616493, 0xB35E82, 0xEB5471, 0xF0768D, 0xFAD1D9, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169,
0x304A84, 0x86648E, 0xD55878, 0xED5874, 0xF59EAE, 0xF5E9EE, 0xAAB5CD, 0x4F6597, 0x07266C, 0x012169, 0x95A2C0, 0xEB4060, 0xE4002B, 0xEB4060, 0x95A2C0, 0x012169, 0x07266C, 0x4E5D90, 0xA16087, 0xE55673, 0xEF6780, 0xF8BCC8, 0xE4E5ED, 0x8C9ABB, 0x304A85, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x0A296E, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169,
0x012169, 0x012169, 0x04236A, 0x44588D, 0x986289, 0xE15675, 0xEE617B, 0xF7B2BF, 0xEBE9EF, 0x96A3C1, 0xB8C1D5, 0xEB4060, 0xE4002B, 0xEB4060, 0xB8BFD3, 0x8F638C, 0xDB5776, 0xEE5C77, 0xF6A8B7, 0xF1EAEF, 0xA0ACC7, 0x455C91, 0x04236A, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x576C9C, 0xBFC7D9, 0x576C9C, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169,
0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xE8264B, 0xE4002B, 0xE8264B, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x05246B, 0x687BA6, 0xC2CADB, 0x697CA6, 0x05246B, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169,
0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0xE4002B, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x05246B, 0x012169, 0x05246B, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169,
0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xE8264B, 0xE4002B, 0xE8264B, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0xF499AA, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x06256C, 0x0F2D71, 0x1E3A7A, 0x07266C, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169,
0x012169, 0x012169, 0x04236A, 0x445C91, 0xA0ACC7, 0xF1EAEF, 0xF6A8B7, 0xEE5C77, 0xDC5776, 0x8F638C, 0xB8BFD3, 0xEB4060, 0xE4002B, 0xEB4060, 0xB8C1D5, 0x96A3C1, 0xEBE9EF, 0xF7B2BF, 0xEE617B, 0xE15675, 0x986289, 0x44588D, 0x04236A, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x143274, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x25407E, 0xE2E6EE, 0xECEEF4, 0x385189, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169,
0x304A85, 0x8B9ABB, 0xE4E5ED, 0xF8BDC8, 0xEF6780, 0xE55673, 0xA16087, 0x4E5D90, 0x07266C, 0x012169, 0x95A2C0, 0xEB4060, 0xE4002B, 0xEB4060, 0x95A2C0, 0x012169, 0x07266C, 0x4F6597, 0xAAB5CD, 0xF5E9EE, 0xF59EAE, 0xED5874, 0xD55878, 0x86648E, 0x304A85, 0x012169, 0x012169, 0x012169, 0x012169, 0x04246B, 0x97A4C1, 0xD7DCE7, 0x40588E, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x586D9D, 0x6074A1, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169,
0xFAD1D9, 0xF0768D, 0xEB5471, 0xB35E82, 0x616493, 0x102E72, 0x012169, 0x012169, 0x012169, 0x012169, 0x95A2C0, 0xEB4060, 0xE4002B, 0xEB4060, 0x95A2C0, 0x012169, 0x012169, 0x012169, 0x012169, 0x102E72, 0x6376A3, 0xBEC6D9, 0xFAE1E7, 0xF28A9D, 0xED5471, 0x012169, 0x012169, 0x012169, 0x012169, 0x0F2D71, 0x798AB0, 0xA3AFC9, 0x2A4581, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169,
0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x6679A4, 0x6679A4, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169,
0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x06256C, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x1E3A7A, 0x1E3A7A, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169,
0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x0B296F, 0x03236A, 0x012169, 0x9FABC6, 0x012169, 0x03236A, 0x0B296F, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169,
0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x0A296E, 0xAFB9D0, 0xB7C0D5, 0xFFFFFF, 0xB7C0D4, 0xAFB9D0, 0x0A296F, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169,
0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x2F4984, 0xA8B3CB, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xA8B3CC, 0x2F4984, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x0A296E, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169,
0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x02226A, 0x24407E, 0x354E87, 0xE7EAF1, 0xE1E4ED, 0xE7EAF1, 0x354E88, 0x25407E, 0x03226A, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x576C9C, 0xBFC7D9, 0x576C9C, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169,
0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x0A296E, 0x7385AC, 0x03236A, 0x7385AC, 0x0A296E, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x05246B, 0x687BA6, 0xC2CADB, 0x697CA6, 0x05246B, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169,
0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x05246B, 0x012169, 0x05246B, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169,
0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169, 0x012169,
1 thought on “Image to RGB Array”