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

  1. 4 months ago

    Emile S

    Aug 10 Europe (France, Strasbourg)

    a. The Transform.Surface example is wrong (in both the BI_LR and http://docs.xojo.com/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.

  2. Emile S

    Aug 10 Europe (France, Strasbourg)

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

  3. Emile S

    Aug 10 Europe (France, Strasbourg)

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

    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
  4. Jeff T

    Aug 10 Pre-Release Testers Midlands of England, Europe

    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.

    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

or Sign Up to reply!