Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8499431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:39:54+00:00 2026-06-11T00:39:54+00:00

I have been having a tough time creating a thumbnail that is not horrible

  • 0

I have been having a tough time creating a thumbnail that is not horrible quality. So far the best code i’ve come up with is:

Bitmap bmp = new Bitmap(width, height);
Graphics graphic = Graphics.FromImage(bmp);
graphic.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphic.SmoothingMode = SmoothingMode.HighQuality;
graphic.PixelOffsetMode = PixelOffsetMode.HighQuality;
graphic.CompositingQuality = CompositingQuality.HighQuality;
graphic.DrawImage(photo, 0, 0, width, height);
return imageToByteArray(bmp);

Which produces this gem:

enter image description here

If I resize the same image in Paint.NET i get this:

enter image description here

Which is WAY better. Everything I’ve found on line points me to some variation of the code I have above. I know Paint.NET was open source at one point. Does anyone know what magic they were doing to create such nice resize functionality and if that functionality can be reproduced in C#?

UPDATE:

The original image from this example was a jpg

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:39:56+00:00Added an answer on June 11, 2026 at 12:39 am

    GIFs

    I recalled reading that .NET has issues with palette-based formats, like GIF, so I dug up a few articles.

    This article describes how to quantize (pick an optimum palette) to improve quality: http://msdn.microsoft.com/en-us/library/aa479306.aspx, as does this (badly formatted) article.

    In brief, I believe GDI+ picks a non-optimum palette when performing the resize.

    PNGs

    PNGs are palette-based, so they may be prone to the same issues as GIFs. I’m not sure if it matters that the palette can be much larger.

    JPEG-friendly example

    This code should work fine on JPEGs (but does not render GIFs smoothly). If you try it and it pixelates a JPEG, then there is probably something else going on.

    private static byte[] GetScaledImage( byte[] inputBytes, int width, int height ) {
        Image img = null;
    
        using( MemoryStream ms = new MemoryStream() ) {
            ms.Write( inputBytes, 0, inputBytes.Length );
            img = Image.FromStream( ms );
        }
    
        using( MemoryStream ms = new MemoryStream() ) {
            using( Image newImg = new Bitmap( width, height ) ) {
                using( Graphics g = Graphics.FromImage( newImg ) ) {
                    g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    g.DrawImage( img, 0, 0, width, height );
    
                    newImg.Save( ms, img.RawFormat );
                    return ms.GetBuffer();
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been having a tough time getting an attendance table for a classroom
OK, so I have been having a bit of a tough time with webcam
I have been doing some reading, and I'm having a tough time understanding how
I have been having problems with creating a download list of files for a
I have been having an issue with the $this->delete() method that deletes a record
So, I have been having a bear of a time trying to troubleshoot why
I have been having the hardest time trying to resolve the weirdest error when
I've been having a tough time getting jRuby on Rails 3 deployed on Tomcat
I have been having trouble pulling up a custom UIPickerView from the textfield's inputview
I have been having these really odd problems with Visual Studio 2010. At this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.