BI_LR: Transform.Surface example is wrong / does not works

a. The Transform.Surface example is wrong (in both the BI_LR and http://documentation.xojo.com/api/graphics/rgbsurface.html#rgbsurface-transform):

Const kMaxMapOffset = 255 Dim map(MaxMapOffset) As Integer For i As Integer = 0 To kMaxMapOffset map(i) = kMaxMapOffset - i Next somePicture.RGBSurface.Transform(map)

b. Transform.Surface example does not works
A red bug appears on the last line (I changed somePicture to a real Picture with a loaded png file).

I nearly forgot:
El Capitan (10.11.6)
Xojo 2019r1.1

Works fine with 2015r1.

Step b above: the Picture must have a valid .Graphics !
else, a crash occured…

AFAIK, the code below does not adds a Graphics… and I use that often, very often :frowning:

[code]Dim picFile As FolderItem
picFile = GetOpenFolderItem("")

If picFile <> Nil Then
Dim pic As Picture
pic = Picture.Open(picFile)
Canvas1.Backdrop = pic // Was: ImageWell1.Image = pic
End If[/code]

If I remember rightly, a loaded picture may be imutable… you cant change it
Instead, create a picture in code of the same size, and copy the loaded on to the created on
Then you can amend your local copy.

[code]Dim picFile As FolderItem
picFile = GetOpenFolderItem("")
Dim loadpic As Picture
Dim Mypic As Picture

If picFile <> Nil Then
try
loadpic = Picture.Open(picFile)

Mypic = new picture (loadpic.width, loadpic.height)
mypic.graphics.drawpicture loadpic,0,0
catch
//problem
end try

Canvas1.Backdrop = Mypic // Was: ImageWell1.Image = pic
End If[/code]