GdipSetInterpolationMode

I’m upgrading from Xojo 2019 to 2022.

In 2019, I had this code to get higher quality drawing:

Public Sub SetGDIInterpolationMode(g as Graphics)
  #if TargetWin32
    // sets high quality interpolation mode for resizing info
    // useful when using @2x retina graphics on Win32 
    //
    // Note: you set this on the destination graphics, not on the source
    // see https://forum.xojo.com/9403-scale-quality-of-canvas-control/0
    if g = nil then
      return
    end if
    dim ghnd as integer = g.Handle(Graphics.HandleTypeGDIPlusGraphics)
    // see https://msdn.microsoft.com/en-us/library/windows/desktop/ms534141(v=vs.85).aspx
    Soft Declare Function GdipSetInterpolationMode Lib "gdiplus" (graphicsHandle as int32, Mode as int32) As int32
    
    const InterpolationModeDefault = 0
    const InterpolationModeLowQuality = 1
    const InterpolationModeHighQuality = 2
    const InterpolationModeBilinear = 3
    const InterpolationModeBicubic = 4
    const InterpolationModeNearestNeighbor = 5
    const InterpolationModeHighQualityBilinear = 6
    const InterpolationModeHighQualityBicubic = 7
    
    dim mode as integer = InterpolationModeHighQualityBicubic    
       
    call GdipSetInterpolationMode(ghnd,mode)
  #endif

End Sub

This no longer compiles in 2022.

Is it still needed? If so, what’s the new method?

I would think this is gone since GDI plus is no longer used at all ?

1 Like

I think you are right. Is there an explanation of the new graphics framework xojo is using these days?

Its called Direct2D.

There is some info on Microsoft web. Though its sort of sparse, its not used all that much.

There is now an AntiAliasMode property built into the graphics class. I’ve never used it but it might be a suitable replacement.

Thanks! - but it appears to have a documentation bug - it’s not a Boolean…

https://documentation.xojo.com/api/graphics/graphics.html#graphics-antialiasmode

AntiAliasMode As Boolean

Controls the level of interpolation/quality when drawing scaled Pictures. Valid modes are from the Graphics.AntiAliasModes enumeration: LowQuality, DefaultQuality, and HighQuality. The default is DefaultQuality.

Use High Quality (set in Paint event of a Canvas):