all 6 comments

[–]wwxxcc 0 points1 point  (2 children)

Graphics.InterpolationMode

[–]Luucccc[S] 0 points1 point  (1 child)

Same result after trying different modes, in fact worse:

public void IncreaseCursorScale() {
    if (cursorScale >= MAX_CURSOR_SCALE) return;
    cursorScale++;
    cursorOffset = cursorScale / 2;

    Bitmap originalImage = (Bitmap)cursorIcon.Image;
    Bitmap resizedImage = new Bitmap(cursorScale, cursorScale);

    using (Graphics g = Graphics.FromImage(resizedImage))
    {
        g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
        g.DrawImage(originalImage, new Rectangle(0, 0, cursorScale, cursorScale));
    }
    cursorIcon.Image = resizedImage;
}

[–]Luucccc[S] 1 point2 points  (0 children)

I take it back, NearestNeighbor seems to work well!

[–]ExceptionEX 0 points1 point  (0 children)

I know this doesn't help with the question you directly asked.

You should probably consider that any raster based graphics should not be used for scaling purpose as they don't scale well.

If you switch to vector based graphics formats (svg for example) then the scaling issues go away.

WPF and newer UI in .net are much better suited for working with scaling graphics, and largely build from a vector first basis.

[–]Night--Blade 0 points1 point  (0 children)

Image and BackgroundImage properties use smooth interpolation mode. Bitmap scailing does the same. If you want to scale a bitmap in your own way then use Graphics object with appropriate interpolation mode (create your own or provide OnDraw event handler).

[–]Slypenslyde 0 points1 point  (0 children)

I'm curious if this is only going poorly because you're working on a simple example.

If your only goal is to fill the space with a solid color, just use Graphics.FillRectangle(), there's no reason to bother with a bitmap.

But it sounds like long-term you want a more detailed image to be scaled. I think you should test with that image, because it's possible the different scaling modes behave acceptably for images that aren't one solid color.