How to display a picture in perspective?

Hello
I still found some old image distortions

and now try to adapt it to 2021
here my first attempt

https://www.dropbox.com/s/v3p8kugeg0l6rqj/picture-tool.xojo_binary_project?dl=1

1 Like

Thanks, Rudolf. Works beautifully and without plugins !

1 Like

@RudolfJ I have a question about the code, maybe you can help. The perspective is always drawn on the bottom of the rectangle. Only when doing a couple of rotations, it will draw it on the right (like in your screenshot).

Do you know which parameter I need to tweak so that it draws the perspective on the right side directly (without needing rotations)? I suspect it should be something in the method ‘neuunten’.

Const Pi = 3.14159
Var mx,my,b,h As Integer
Var i,ii,x As Integer
Var surf,burf As RGBSurface
Var lpic,neu As picture
Var z,r As Double

h = blatt.height -1
b =blatt.Width-1
lpic = New picture(b,2) // als shape testen
surf = blatt.rgbsurface
burf = lpic.RGBSurface
x= b/4
neu = New picture(b1.5,h1.5)
z= 5
r=0
neu.graphics.Translate(canvas2.width/2,canvas2.height/2)
neu.graphics.Rotate(slider1.value / 57.29577951311) // angle 0- 360
For ii = 0 To h

For i = 0 To b
burf.Pixel(i,0) = surf.pixel(i,ii)
'If checkbox5.value Then burf.Pixel(i,1) = surf.pixel(i,ii)
Next
neu.graphics.Drawpicture lpic,r,z,b-r*2,2,0,0,b,2
z=z+textfield3.Text.Val/10
r=r +TextField4.Text.Val/10
Next

px= New pixmapshape(neu)

canvas2.Invalidate

Hallo Vincent
I missed your question.
my answer is a bit late but the code is faster now

https://www.dropbox.com/s/ipfa9og3ufjtn59/drawpicture-Examble-fast04.xojo_binary_project?dl=1

… or perhaps using OpenGL and some basic 3D :wink:

Geoff

1 Like

be aware that OpenGL in Xojo is very outdated …

The example is based on Jeff Quan’s external GL plug-ins, which I’m told, is working on top of Metal.

1 Like