Jump to content

Plug-in Request - convert to 256 colors

Recommended Posts

In MSPaint you have the option to save bmp images in 256 and 16 colors. Is there be a way to make a converter in PdN to reduce the number of colors in a selected area (plug-in maybe)? this would make the image look similar to SearedIce's Cutout Effect http://paintdotnet.12.forumer.com/viewtopic.php?t=1100.


Take responsibility for your own intelligence. ;) -Rick Brewster

Link to comment
Share on other sites

int interval = 64;
int R;
int B;
int G;
int A;
float divR;
float divB;
float divG;
float divA;
ColorBgra fin;

void Render(Surface dst, Surface src, Rectangle rect)
   for(int y = rect.Top; y < rect.Bottom; y++)

       for (int x = rect.Left; x < rect.Right; x++)
          ColorBgra source = src[x, y];
           divR = source.R/interval;
           divB = source.B/interval;
           divG = source.G/interval;
           divA = source.A/interval;
           R = (int)System.Math.Round(divR);
           B = (int)System.Math.Round(divB);
           G = (int)System.Math.Round(divG);
           A = (int)System.Math.Round(divA);
           R = R * interval;
           B = B * interval;
           G = G * interval;
           A = 255; //A * interval;
           fin.R = (byte)(R);
           fin.B = (byte)(;
           fin.G = (byte)(G);
           fin.A = (byte)(A);
           dst[x, y] =  fin;

I love math.

Explanation: a codelab script to make 256 colors without diffusion or dithering.

Also, for 16 colors, change int interval = 64; to int interval = 128; . And yes, this can be simplified. I just don't feel like it.


Link to comment
Share on other sites

  • 3 years later...

I have a low color file type plugin that supports saving images to 1bit, 4bit, 8bit and 16bit color depths. viewtopic.php?f=16&t=30638

Also without examining the code posted too much, does it do anything different to the Posterize effect (incuded in Paint.net)? I think setting each Posterize value to 8 (for Red, Green, Blue) will result in 256 possible colors

Don't know what plugin to use? Try looking in the plugin gallery

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Create New...