예제 #1
0
GMatrix<float> RectToRect(const GRect& src, const GRect& dst)
{
  // Make translation matrix of the source from the origin
  GMatrix<float> SrcTranslate;
  SrcTranslate.setTranslation(-src.left(), -src.top());

  // Make scale matrix of dx, dy. Dst / Src
  GMatrix<float> Scale;
  Scale.setScale(dst.width() / src.width(), dst.height() / src.height());

  // Get translation matrix of the dst rectangle
  GMatrix<float> DstTranslate;
  DstTranslate.setTranslation(dst.left(), dst.top());

  // Concatenate the 3 matrices. DstTranslate * Scale * SrcTranslate
  DstTranslate.concat(Scale).concat(SrcTranslate);

  return DstTranslate;
}