29 lines
825 B
C++
29 lines
825 B
C++
#include <mdiwin/txlmtrx.hpp>
|
|
|
|
int TranslationMatrix::smTransformMatrix[][2]={{1,0},{0,1}};
|
|
|
|
void TranslationMatrix::performTranslation(void)
|
|
{
|
|
int newx;
|
|
int newy;
|
|
|
|
if(mOffsetRows>=mRows)mOffsetRows%=mRows;
|
|
if(mOffsetCols>=mCols)mOffsetCols%=mCols;
|
|
if(mOffsetRows<=(-mRows))mOffsetRows%=mRows;
|
|
if(mOffsetCols<=(-mCols))mOffsetCols%=mCols;
|
|
for(int row=0;row<mRows;row++)
|
|
{
|
|
for(int col=0;col<mCols;col++)
|
|
{
|
|
newx=(smTransformMatrix[0][0]*row)+(smTransformMatrix[1][0]*col)+mOffsetRows;
|
|
newy=(smTransformMatrix[0][1]*row)+(smTransformMatrix[1][1]*col)+mOffsetCols;
|
|
if(newx<0)newx=mRows+newx;
|
|
if(newy<0)newy=mCols+newy;
|
|
if(newx>=mRows)newx-=mRows;
|
|
if(newy>=mCols)newy-=mCols;
|
|
*(((*mOutputPtr)+((LONG)mCols*(LONG)newx)+(LONG)newy))=
|
|
*(((*mInputPtr)+((LONG)mCols*(LONG)row)+(LONG)col));
|
|
}
|
|
}
|
|
}
|