I'm testing out an algorithm I found on a few C++ sites for doing a destination-source mapped bitmap rotate, and it all works, except I can't translate the rotation from 0,0 to the centerpoint. The first time I messed with it, I got it to work, but I can't figure out how I did it.I figure Zaei or someone else mathy can help me (I still haven't taken any advanced math or geometry).
Don't worry about the calls and everything, they all work fine.
RotateRect calculates the necessary Width and Height to contain the rotated image.
Resize resizes the buffer to hold it.
GetPixelAARolloff is basically GetPixel, but BiLinear.
VB Code:
sAngle = Angle * (c_dblPi / 180) duCol = Sin(-sAngle) * (1) dvCol = Cos(-sAngle) * (1) m_dblX2 = SourceImage.Width m_dblY2 = SourceImage.Height SoftFX.RotateRect m_dblX2, m_dblY2, m_dblXO, m_dblYO, CDbl(sAngle) DestImage.Resize m_dblX2, m_dblY2 X = m_dblX2 / 2 Y = m_dblY2 / 2 DestImage.Clear F2RGB(64, 96, 128, 0) duRow = dvCol dvRow = -duCol startu = (SourceImage.Width / 2) startv = (SourceImage.Height / 2) rowu = startu - ((X * duCol) + (Y * duRow)) rowv = startv - ((X * dvCol) + (Y * dvRow)) For dY = 0 To DestImage.Height - 1 sX = rowu sY = rowv For dX = 0 To DestImage.Width - 1 DestImage.SetPixel dX, dY, SourceImage.GetPixelAARolloff(sX, sY) sX = sX + duRow sY = sY + dvRow Next dX rowu = rowu + duCol rowv = rowv + dvCol Next dY




I figure Zaei or someone else mathy can help me (I still haven't taken any advanced math or geometry).
Reply With Quote