1
Bitmap outputBitmap = new Bitmap(inputBitmap.Width * 5, inputBitmap.Height * 5);

using (Graphics graphics = Graphics.FromImage(outputBitmap))
    {                        
    graphics.CompositingQuality =
        System.Drawing.Drawing2D.CompositingQuality.HighQuality;
    graphics.InterpolationMode =
        System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
    graphics.SmoothingMode =
        System.Drawing.Drawing2D.SmoothingMode.HighQuality;

    graphics.DrawImage(inputBitmap, 0, 0,
        inputBitmap.Width * 5, inputBitmap.Height * 5);
    }

The result is an upscaled image offset by a few pixels in direction of top left corner. what it should look like and what it looks like

How do I make this right?

svick
  • 236,525
  • 50
  • 385
  • 514
user1306322
  • 8,561
  • 18
  • 61
  • 122
  • I just tried the exact same thing, but can't see the offset you mention. Here's the entire Program.cs in my test project. http://pastebin.com/2S1Y6F7D – Ani May 15 '12 at 18:18
  • Duplicate of http://stackoverflow.com/questions/249587/high-quality-image-scaling-c-sharp ? – Peter Ritchie May 15 '12 at 18:29
  • @PeterRitchie nope, not about HQ scaling, just about how it's not even satisfactory by default. First and third parameters can actually be omitted and the result will be the same. – user1306322 May 15 '12 at 22:42

0 Answers0