Sunday, 25 August 2013

How to add variable degree of dithering to a color bitmap with floyd-steinberg using a custom palette in C#

How to add variable degree of dithering to a color bitmap with
floyd-steinberg using a custom palette in C#

I know I'm asking a lot here, but... I have seen plenty of C# code
postings for floyd-steinberg dithering. Most don't work due to bugs. Most
of them turn the image into greyscale, which I can't allow. None of them
allow for a variable degree of dithering... it's always 100% maximum
dithering. And absolutely none of them allow me any options to specify a
custom palette / color table to be used in the final image.
What I'm looking for is working C# code that will allow me to call a
function such as:
DitherImage(mypic, ditheramount, custompalette)
..which will accept the following variables:
mypic, which is a bitmap() of any pixelformat, to be dithered.
ditheramount, which is an integer from 0 to 100. And custompalette, which
is an array of colors.
The function should simply return the dithered bitmap. The returned bitmap
should not contain any colors that were not in the custompalette array.
Again, I know I'm asking a lot, but if anyone happens to have code like
this and would like to share it, or you know where code like this is
already posted online, I would be most grateful.

No comments:

Post a Comment