Loading...

FloydSteinberg

Example requests & Code samples for GdPicture.NET Toolkits.

FloydSteinberg

Postby robduff » Thu Jun 02, 2011 7:07 pm

I need to reduce the number of colors in images and then dither them so there is no banding. Does GdPicture support the Floyd Steinberg dithering method? I know there is a bitonal method FxBlackNWhite that does, but I need to retain the colors. Here are my basic requirements:
1. Convert incoming color images to RGB565.
2. Remove/reduce banding caused by the color reduction.
3. Save as the images as PNG files.

I have attached an example image I have been working with that I have been attempting to convert to RGB565 and then remove the banding. Note the image prior to conversion already has some light banding. The goal is to greatly reduce or remove the banding all together.

Any help or suggestions would be greatly appreciated.
Attachments
WhereWeJet-24bit.PNG
Test image that needs to be converted to RGB565 with no banding.
robduff
 
Posts: 7
Joined: Thu May 05, 2011 4:47 pm

Re: FloydSteinberg

Postby Loïc » Fri Jun 03, 2011 10:20 am

Hi,

You can use a workaround consisting to use our GIF encoder that applies dithering on colors.
Here a snippet, let me know if you need more information:
Code: Select all

      Dim ms As IO.Stream = New IO.MemoryStream
      Dim ImageID As Integer = Imaging1.CreateGdPictureImageFromFile("input.png")
      Imaging1.SaveAsStream(ImageID, ms, DocumentFormat.DocumentFormatGIF, 0)
      Imaging1.ReleaseGdPictureImage(ImageID)

      ImageID = Imaging1.CreateGdPictureImageFromStream(ms)
      Imaging1.SaveAsPng(ImageID, "output.png")
      Imaging1.ReleaseGdPictureImage(ImageID)
      ms.Dispose()
Attachments
dither.png
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4437
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: FloydSteinberg

Postby robduff » Fri Jun 03, 2011 9:49 pm

Your code snippet worked great! Thanks for the response it is much appreciated. It is good to know I will still be able to utilize the license my company purchased.

Here is the snippet in c-sharp revised for my test code:

Code: Select all
            using (System.IO.Stream ms = new System.IO.MemoryStream())
            {
                int intImageID = objGdP.CreateGdPictureImageFromFile(strSrcFile);
                objGdP.SaveAsStream(intImageID, ms, GdPicture.DocumentFormat.DocumentFormatGIF, 0);
                objGdP.ReleaseGdPictureImage(intImageID);

                intImageID = objGdP.CreateGdPictureImageFromStream(ms);
                objGdP.SaveAsPNG(intImageID, strDstFile);
                objGdP.ReleaseGdPictureImage(intImageID);
            }
robduff
 
Posts: 7
Joined: Thu May 05, 2011 4:47 pm

Re: FloydSteinberg

Postby robduff » Mon Jun 06, 2011 8:11 pm

The resulting image is grainy. Is there a way to get a smoother dither?
robduff
 
Posts: 7
Joined: Thu May 05, 2011 4:47 pm


Return to Example requests & Code samples For GdPicture.NET

Who is online

Users browsing this forum: No registered users and 0 guests