Jump to content

Outputting Monochrome Bitmaps


Recommended Posts

I am pleased with the additions to the output file formats that occurred recently. This provided a monochrome, 8 bit per pixel format. I have a need for a monochrome, 1 bit per pixel format. It would be nice to be able to set the threshold for conversion from 8 bits to one bit. Currently I have to save the file from Paint.net and then open it in MS Paint to do the final conversion and I have no threshold control.

Link to comment
Share on other sites

Here is a CodeLab script for the conversion you need:

#region UICode
int Amount1 = 128; // [0,255] Tolerance
#endregion

private UnaryPixelOps.Desaturate desaturateOp = new UnaryPixelOps.Desaturate();

void Render(Surface dst, Surface src, Rectangle rect)
{
  ColorBgra CurrentPixel;
  for (int y = rect.Top; y    {
     for (int x = rect.Left; x       {
        CurrentPixel = desaturateOp.Apply(src[x,y]);
        if (CurrentPixel.R > Amount1)
        {
           CurrentPixel = ColorBgra.Black;
        }
        else
        {
           CurrentPixel = ColorBgra.White;
        }
        dst[x,y] = CurrentPixel;
     }
  }
}

It can be found on this page: http://www.boltbait.com/pdn/codelab/hel ... ments.html as part of the CodeLab help file.

You'll still need to use MS Paint for the final save as Paint.NET does not support 1 bit output formats.

EDIT: Download this plugin pack: viewtopic.php?f=16&t=23885 for better conversions to 1 bit.

Click to play:
j.pngs.pngd.pnga.pngp.png
Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game

Link to comment
Share on other sites

I know this doesn't solve your "1-bit output problem", but you could just use Brightness/Contrast with the Contrast set to 100; this leaves the Brightness control to be used as a makeshift "threshold"...

 

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...