Issues rotating in place

  1. 5 months ago
    Edited 5 months ago by Meade L

    After racking my brain for two days now, I am having a lot of issues with image rotation. I am using MBSRotate to do the rotation, however, I am also trying to scale the image depending on canvas size. This image, optimistically would rotate in the middle of the canvas

    Controls
    OrientationCanvas as Canvas

    Properties
    OrientationOriginal as picture
    OrientationCurrent as picture

    What I have thus far in the method is as follows:

    dim v as double = datalistbox.cell(datalistbox.lastindex,2).val * -1 //This is a listbox that is holding raw, viewable data
    dim p as new Picture (OrientationOriginal.Width,OrientationOriginal.Height,32)
    dim ScaleRatio as Double
    dim w as integer
    dim h as Integer
    
    p.Graphics.DrawPicture (OrientationOriginal,0,0,p.Width,p.Height,0,0,OrientationOriginal.Width,_
    OrientationOriginal.height)
    
    p = p.RotateMBS(v, &cFFFFFF) //Is there any way I could make the backing transparent? Putting in &cFFFFFFFF doesn't work...
    
    ScaleRatio = min(OrientationCanvas.Height/p.Height, OrientationCanvas.width/p.Width)
    
    w = p.Width * ScaleRatio
    h = p.Height * ScaleRatio
    
    dim q as new Picture(w,h,32)
    
    q.Graphics.DrawPicture (p,0,0,w,h,0,0,p.Width,p.Height)
    
    OrientationCurrent = q
    
    OrientationCanvas.Refresh(False)

    Extra Credit
    How would I make the white background made using MBSRotate transparent? Is it possible?

    So, with that, the picture shows at the proper size, but the rotation is FUBAR. HALP! Thanks a bunch in advance!

  2. Norman P

    May 18 Xojo Inc

    Have you tried using Object2D pixmap shape ?
    http://docs.xojo.com/index.php/PixmapShape
    You can create & scale the image as you are already then rotate it using the Object2D

  3. @Norman P Have you tried using Object2D pixmap shape ?
    http://docs.xojo.com/index.php/PixmapShape
    You can create & scale the image as you are already then rotate it using the Object2D

    Would it be able to rotate in place in the center using Pixmap Shape?

  4. Jeff T

    May 18 Midlands of England, Europe

    Would it be able to rotate in place in the center using Pixmap Shape?

    That is already the default behavior

or Sign Up to reply!