Sign in to follow this  
Makuna

Arduino NeoPixel Sketch Exporter

Recommended Posts

const uint16_t myImageWidth = 16;
const uint16_t myImageHeight = 20;
const uint8_t PROGMEM myImage[] = {  // (16 x 20) GRB in Hexadecimal
        0x00, 0xff, 0x00, 0x00, 0x00,

Overview:

This will allow an image file to be exported into a .h file that can be included into a Arduino Sketch.  The image is exported as a PROGMEM data structure for use with the NeoPixelBus Arduino library located at \GitHub\Makuna\NeoPixelBus.

 

Installation:

  • Download the attached zip and copy the contained DLL into your Paint.Net\FileTypes directory. 
  • Restart Paint.Net

How to use:

When you select "Save As", a new file type "Arduino Source File Snippet" will show up in the "save as" dialog.  Selecting this will open the following properties dialog.

 

ConfigUI.jpg

 

Select the color order that your NeoPixel use, this is important as the data structure will contain native image bits for the specific color feature of your pixels.  If your pixels contain a White LED also, make sure to select the correct one ending in W.

 

The layer blend operation allows you to use the layers for specific needs. 

  • Flatten for RGB is the most common. It will flatten all the layers temporarily as it exports the data.  The W channel will always be off.
  • Background only for RGB will only look at the "Background" layer when it exports.  The W channel will always be off.
  • ​Background and White for RGBW will use the "Background" layer for the RGB parts of the data and the "White" layer will be used to create the W channel if present.

By default, Gamma correction is on.  This will help match the image to the Gamma Cure of NeoPixel LEDs.  Turning it off will create data that will have the dim colors come out more bright.

ArduinoProgmemNeoPixelFileType.zip

post-146733-0-63166000-1460776070_thumb.

Edited by Makuna

Share this post


Link to post
Share on other sites

Hey Makuna - nice job on the plugin!

 

I exported a small image using your plugin. The top left pixel is colored #FFB311 (RGB) according to paint.net's color picker.

 

Looking at the output file I couldn't see that pixel data anywhere.

const uint16_t myImageWidth = 6;
const uint16_t myImageHeight = 3;
const uint8_t PROGMEM myImage[] = {  // (6 x 3) RGB in Hexadecimal
        0xff, 0x74, 0x01, 0xff, 0xd5, 0x00, 0xaf, 0xff, 0x00, 0x54, 0xff, 0x00, 0x1c, 0xff, 0x00, 0x03, 0xff, 0x00,
        0xff, 0x47, 0x47, 0xff, 0x88, 0x42, 0xff, 0xff, 0x42, 0x88, 0xff, 0x42, 0x42, 0xff, 0x42, 0x42, 0xff, 0x88,
        0x39, 0x03, 0xff, 0xd7, 0x02, 0xff, 0xff, 0x02, 0x5c, 0xff, 0x02, 0x07, 0xff, 0x33, 0x02, 0xff, 0xd7, 0x02 };

Then I realized that Gamma correction was ON. Toggling it to OFF generated the results I expected.

 

Perhaps Gamma Correction should default to OFF?

 

I'd be interested in the correction color curve if you would like to share it.

Share this post


Link to post
Share on other sites

It is best to leave the correction on by default.  The reason is that a simple color gradiant from black to a color on the NeoPixels will not look linear at all.  NeoPixels are "hot" in the lower portion of brightness values.  When I document the use of this plugin in my NeoPixelBus project I will include when "not" to use it.

 

There are many write-ups on this topic of the gamma curve, and the equation is...

corrected unit value = Math.Pow(unitValue, 1.0 / 0.45)

The feature of my NeoPixelBus that uses this output isn't checked in yet, working on samples before I make the next release there. 

 

At some point I expect the actual chip on the pixels will apply this in the hardware; but until then I wanted to expose it here and in my library.

Edited by Makuna

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this