Masks and AlphaChannels in Xojo …

After using some solutions found on the Xojo forum that were somewhat lacking (eg did not take into account that pictures could have different resolutions) here is a somewhat better (still simple) solution.

If anyone has ideas for improvement then feel free to comment - and sorry, pure Xojo code necessary for this, no plug-ins:

Public Function ConvertToAlphaPicture(input As Picture) as Picture
  
  If input.hasAlphaChannel Then Return input
  
  Dim w As Integer = Input.Width
  Dim h As Integer = Input.Height
  Dim hResolution As Integer = input.HorizontalResolution
  Dim vResolution As Integer = input.VerticalResolution
  
  Dim result As New Picture(w, h)
  result.HorizontalResolution = hResolution
  result.VerticalResolution = vResolution
  
  result.Graphics.DrawPicture(input, 0, 0, w, h, 0, 0, w, h)
  
  Return result
  
End Function
Public Function ConvertToMaskedPicture(input As Picture) as Picture
  
  Dim w As Integer = Input.Width
  Dim h as Integer = Input.Height
  Dim hResolution As Integer = input.HorizontalResolution
  Dim vResolution As Integer = input.VerticalResolution
  
  Dim result As New Picture(w, h, 32)
  result.HorizontalResolution = hResolution
  result.VerticalResolution = vResolution
  
  Dim mask As New Picture(w, h, 32)  // white
  mask.HorizontalResolution = hResolution
  mask.VerticalResolution = vResolution
  
  result.Graphics.DrawPicture(input, 0, 0, w, h, 0, 0, w, h)
  mask.Graphics.DrawPicture(Input.CopyMask, 0, 0, w, h, 0, 0, w, h) 
  
  result.mask = mask
  
  Return result
  
End Function

Regarding ConvertToMaskedPicture:

Note that the default resolution of a picture is 72 dpi but the dropped picture might have much higher resolution (eg 299 dpi)

Though picture and mask look good in the debugger there is some jaggedness if you zoom in on the resulting picture in the canvas (which is not seen with an identical sized canvas displaying the original picture with AlphaChannel).

Even accounting for the resolution does not change that, so my suspicion is that the canvas itself is restricted to 72 dpi and the problem is in its scaling.