Rotozoom without the skew
#1
I was using rotozoom2 when I noticed it was skewing the image it was rotating when xscale and yscale were not identical values.  (I also adjusted it to used degrees as opposed to radians, but that has nothing to do with the skew). 
The change was in multiplying px(0) to px(3) and py(0) to py(3) by the scale factors prior to rotation.

Code: (Select All)
Sub RotoZoom_jan23 (centerX As Long, centerY As Long, Image As Long, xScale As Single, yScale As Single, Rotation As Single)
    Dim px(3) As Single: Dim py(3) As Single
    W& = _Width(Image&): H& = _Height(Image&)
    px(0) = -W& / 2 * xScale: py(0) = -H& / 2 * yScale: px(1) = -W& / 2 * xScale: py(1) = H& / 2 * yScale
    px(2) = W& / 2 * xScale: py(2) = H& / 2 * yScale: px(3) = W& / 2 * xScale: py(3) = -H& / 2 * yScale
    sinr! = Sin(-0.01745329 * Rotation): cosr! = Cos(-0.01745329 * Rotation)
    For i& = 0 To 3
        ' x2& = (px(i&) * cosr! + sinr! * py(i&)) * xScale + centerX: y2& = (py(i&) * cosr! - px(i&) * sinr!) * yScale + centerY
        x2& = (px(i&) * cosr! + sinr! * py(i&)) + centerX: y2& = (py(i&) * cosr! - px(i&) * sinr!) + centerY
        px(i&) = x2&: py(i&) = y2&
    Next
    _MapTriangle (0, 0)-(0, H& - 1)-(W& - 1, H& - 1), Image& To(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
    _MapTriangle (0, 0)-(W& - 1, 0)-(W& - 1, H& - 1), Image& To(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
End Sub
Reply


Messages In This Thread
Rotozoom without the skew - by James D Jarvis - 01-19-2023, 02:50 AM
RE: Rotozoom without the skew - by bplus - 01-19-2023, 05:29 AM
RE: Rotozoom without the skew - by James D Jarvis - 01-19-2023, 03:47 PM
RE: Rotozoom without the skew - by TerryRitchie - 01-19-2023, 03:54 PM
RE: Rotozoom without the skew - by bplus - 01-19-2023, 05:52 PM
RE: Rotozoom without the skew - by bplus - 01-19-2023, 07:02 PM
RE: Rotozoom without the skew - by bplus - 01-20-2023, 05:28 PM
RE: Rotozoom without the skew - by OldMoses - 01-21-2023, 06:17 PM
RE: Rotozoom without the skew - by SMcNeill - 01-21-2023, 07:10 PM
RE: Rotozoom without the skew - by James D Jarvis - 01-21-2023, 07:27 PM
RE: Rotozoom without the skew - by SMcNeill - 01-21-2023, 09:10 PM
RE: Rotozoom without the skew - by James D Jarvis - 01-21-2023, 07:21 PM
RE: Rotozoom without the skew - by bplus - 01-21-2023, 07:23 PM
RE: Rotozoom without the skew - by SMcNeill - 01-21-2023, 09:22 PM
RE: Rotozoom without the skew - by James D Jarvis - 01-21-2023, 11:06 PM
RE: Rotozoom without the skew - by James D Jarvis - 01-21-2023, 11:09 PM
RE: Rotozoom without the skew - by bplus - 01-22-2023, 03:33 PM



Users browsing this thread: 1 Guest(s)