/* */ package quicktime.std.image;
/* */
/* */ import java.io.IOException;
/* */ import java.io.ObjectInputStream;
/* */ import java.io.ObjectOutputStream;
/* */ import quicktime.QTException;
/* */ import quicktime.QTObject;
/* */ import quicktime.QTSession;
/* */ import quicktime.qd.QDPoint;
/* */ import quicktime.qd.QDRect;
/* */ import quicktime.qd.Region;
/* */ import quicktime.std.StdQTException;
/* */ import quicktime.util.EndianOrder;
/* */ import quicktime.util.QTByteObject;
/* */ import quicktime.util.QTUtils;
/* */
/* */ public final class Matrix extends QTByteObject
/* */ implements Cloneable
/* */ {
/* 25 */ private static boolean apriori = QTSession.apriori();
/* */ public static final int kNativeSize = 36;
/* */ private static final long serialVersionUID = -3479751345142891528L;
/* */
/* */ public Matrix()
/* */ {
/* 48 */ super(36);
/* */
/* 52 */ setIdentity();
/* */ }
/* */
/* */ private Matrix(byte[] paramArrayOfByte) {
/* 56 */ super(paramArrayOfByte);
/* */ }
/* */
/* */ public Matrix(float[][] paramArrayOfFloat)
/* */ {
/* 65 */ super(36);
/* 66 */ setSx(paramArrayOfFloat[0][0]);
/* 67 */ setB(paramArrayOfFloat[0][1]);
/* 68 */ setU(paramArrayOfFloat[0][2]);
/* 69 */ setC(paramArrayOfFloat[1][0]);
/* 70 */ setSy(paramArrayOfFloat[1][1]);
/* 71 */ setV(paramArrayOfFloat[1][2]);
/* 72 */ setTx(paramArrayOfFloat[2][0]);
/* 73 */ setTy(paramArrayOfFloat[2][1]);
/* 74 */ setW(paramArrayOfFloat[2][2]);
/* */ }
/* */
/* */ public Matrix(QDPoint[] paramArrayOfQDPoint1, QDPoint[] paramArrayOfQDPoint2)
/* */ throws QTException
/* */ {
/* 88 */ this();
/* 89 */ if ((paramArrayOfQDPoint1.length < 4) || (paramArrayOfQDPoint2.length < 4) || (QTSession.getQTMajorVersion() < 4))
/* 90 */ throw new StdQTException(-50);
/* 91 */ int[] arrayOfInt1 = DoublePts2FixedPts(paramArrayOfQDPoint1);
/* 92 */ int[] arrayOfInt2 = DoublePts2FixedPts(paramArrayOfQDPoint2);
/* 93 */ int i = QuadToQuadMatrix(arrayOfInt1, arrayOfInt2, getBytes());
/* 94 */ StdQTException.checkError(i);
/* */ }
/* */
/* */ private static int[] DoublePts2FixedPts(QDPoint[] paramArrayOfQDPoint)
/* */ throws QTException
/* */ {
/* 104 */ if (paramArrayOfQDPoint == null) return null;
/* */
/* 106 */ int[] arrayOfInt = new int[paramArrayOfQDPoint.length * 2];
/* 107 */ for (int i = 0; i < paramArrayOfQDPoint.length; i++) {
/* 108 */ arrayOfInt[(i * 2)] = QTUtils.X2Fix(paramArrayOfQDPoint[i].getXF());
/* 109 */ arrayOfInt[(i * 2 + 1)] = QTUtils.X2Fix(paramArrayOfQDPoint[i].getYF());
/* */ }
/* 111 */ return arrayOfInt;
/* */ }
/* */
/* */ private static void FixedPts2DoublePts(int[] paramArrayOfInt, QDPoint[] paramArrayOfQDPoint) throws QTException
/* */ {
/* 116 */ if ((paramArrayOfInt == null) || (paramArrayOfQDPoint == null)) return;
/* */
/* 118 */ for (int i = 0; i < paramArrayOfQDPoint.length; i++) {
/* 119 */ paramArrayOfQDPoint[i].setX(QTUtils.Fix2X(paramArrayOfInt[(i * 2)]));
/* 120 */ paramArrayOfQDPoint[i].setY(QTUtils.Fix2X(paramArrayOfInt[(i * 2 + 1)]));
/* */ }
/* */ }
/* */
/* */ private static int[] DoublePt2FixedPt(QDPoint paramQDPoint) throws QTException {
/* 125 */ if (paramQDPoint == null) return null;
/* 126 */ int[] arrayOfInt = new int[2];
/* 127 */ arrayOfInt[0] = QTUtils.X2Fix(paramQDPoint.getXF());
/* 128 */ arrayOfInt[1] = QTUtils.X2Fix(paramQDPoint.getYF());
/* 129 */ return arrayOfInt;
/* */ }
/* */
/* */ private static void FixedPt2DoublePt(int[] paramArrayOfInt, QDPoint paramQDPoint) throws QTException
/* */ {
/* 134 */ if ((paramArrayOfInt == null) || (paramQDPoint == null)) return;
/* */
/* 136 */ paramQDPoint.setX(QTUtils.Fix2X(paramArrayOfInt[0]));
/* 137 */ paramQDPoint.setY(QTUtils.Fix2X(paramArrayOfInt[1]));
/* */ }
/* */
/* */ private void readObject(ObjectInputStream paramObjectInputStream)
/* */ throws IOException
/* */ {
/* 145 */ this.bytes = new byte[36];
/* */
/* 147 */ paramObjectInputStream.read(this.bytes);
/* */
/* 150 */ for (int i = 0; i < 36; i += 4)
/* */ {
/* 152 */ int j = getIntFromArray(this.bytes, i);
/* 153 */ int k = EndianOrder.flipBigEndianToNative32(j);
/* 154 */ setIntInArray(this.bytes, i, k);
/* */ }
/* */ }
/* */
/* */ private void writeObject(ObjectOutputStream paramObjectOutputStream)
/* */ throws IOException
/* */ {
/* 161 */ byte[] arrayOfByte = new byte[36];
/* */
/* 164 */ for (int i = 0; i < getBytes().length; i += 4)
/* */ {
/* 166 */ int j = getIntFromArray(getBytes(), i);
/* 167 */ int k = EndianOrder.flipNativeToBigEndian32(j);
/* 168 */ setIntInArray(arrayOfByte, i, k);
/* */ }
/* */
/* 171 */ paramObjectOutputStream.write(arrayOfByte);
/* */ }
/* */
/* */ public void setTx(float paramFloat)
/* */ {
/* 180 */ setIntAt(24, QTUtils.X2Fix(paramFloat));
/* */ }
/* */
/* */ public float getTx()
/* */ {
/* 186 */ return QTUtils.Fix2X(getIntAt(24));
/* */ }
/* */
/* */ public void setTy(float paramFloat)
/* */ {
/* 192 */ setIntAt(28, QTUtils.X2Fix(paramFloat));
/* */ }
/* */
/* */ public float getTy()
/* */ {
/* 198 */ return QTUtils.Fix2X(getIntAt(28));
/* */ }
/* */
/* */ public void setSx(float paramFloat)
/* */ {
/* 203 */ setIntAt(0, QTUtils.X2Fix(paramFloat));
/* */ }
/* */
/* */ public float getSx()
/* */ {
/* 209 */ return QTUtils.Fix2X(getIntAt(0));
/* */ }
/* */
/* */ public void setSy(float paramFloat)
/* */ {
/* 215 */ setIntAt(16, QTUtils.X2Fix(paramFloat));
/* */ }
/* */
/* */ public float getSy()
/* */ {
/* 221 */ return QTUtils.Fix2X(getIntAt(16));
/* */ }
/* */
/* */ public void setB(float paramFloat)
/* */ {
/* 227 */ setIntAt(4, QTUtils.X2Fix(paramFloat));
/* */ }
/* */
/* */ public float getB()
/* */ {
/* 233 */ return QTUtils.Fix2X(getIntAt(4));
/* */ }
/* */
/* */ public void setU(float paramFloat)
/* */ {
/* 239 */ setIntAt(8, QTUtils.X2Fract(paramFloat));
/* */ }
/* */
/* */ public float getU()
/* */ {
/* 245 */ return QTUtils.Fract2X(getIntAt(8));
/* */ }
/* */
/* */ public void setC(float paramFloat)
/* */ {
/* 251 */ setIntAt(12, QTUtils.X2Fix(paramFloat));
/* */ }
/* */
/* */ public float getC()
/* */ {
/* 257 */ return QTUtils.Fix2X(getIntAt(12));
/* */ }
/* */
/* */ public void setV(float paramFloat)
/* */ {
/* 263 */ setIntAt(20, QTUtils.X2Fract(paramFloat));
/* */ }
/* */
/* */ public float getV()
/* */ {
/* 269 */ return QTUtils.Fract2X(getIntAt(20));
/* */ }
/* */
/* */ public void setW(float paramFloat)
/* */ {
/* 275 */ setIntAt(32, QTUtils.X2Fract(paramFloat));
/* */ }
/* */
/* */ public float getW()
/* */ {
/* 281 */ return QTUtils.Fract2X(getIntAt(32));
/* */ }
/* */
/* */ public short getType()
/* */ {
/* 288 */ return GetMatrixType(getBytes());
/* */ }
/* */
/* */ public boolean isIdentity()
/* */ {
/* 293 */ return getType() == 0;
/* */ }
/* */
/* */ public void setIdentity()
/* */ {
/* 300 */ SetIdentityMatrix(getBytes());
/* */ }
/* */
/* */ public void translate(float paramFloat1, float paramFloat2)
/* */ {
/* 311 */ TranslateMatrix(getBytes(), QTUtils.X2Fix(paramFloat1), QTUtils.X2Fix(paramFloat2));
/* */ }
/* */
/* */ public void rotate(float paramFloat1, float paramFloat2, float paramFloat3)
/* */ {
/* 323 */ RotateMatrix(getBytes(), QTUtils.X2Fix(paramFloat1), QTUtils.X2Fix(paramFloat2), QTUtils.X2Fix(paramFloat3));
/* */ }
/* */
/* */ public void scale(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4)
/* */ {
/* 335 */ ScaleMatrix(getBytes(), QTUtils.X2Fix(paramFloat1), QTUtils.X2Fix(paramFloat2), QTUtils.X2Fix(paramFloat3), QTUtils.X2Fix(paramFloat4));
/* */ }
/* */
/* */ public void skew(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4)
/* */ {
/* 347 */ SkewMatrix(getBytes(), QTUtils.X2Fix(paramFloat1), QTUtils.X2Fix(paramFloat2), QTUtils.X2Fix(paramFloat3), QTUtils.X2Fix(paramFloat4));
/* */ }
/* */
/* */ public boolean inverse(Matrix paramMatrix)
/* */ {
/* 357 */ return InverseMatrix(getBytes(), paramMatrix.getBytes()) != 0;
/* */ }
/* */
/* */ public void concat(Matrix paramMatrix)
/* */ {
/* 366 */ ConcatMatrix(getBytes(), paramMatrix.getBytes());
/* */ }
/* */
/* */ public void transformDPoints(QDPoint paramQDPoint)
/* */ throws QTException
/* */ {
/* 374 */ int[] arrayOfInt = DoublePt2FixedPt(paramQDPoint);
/* 375 */ int i = TransformFixedPoints(getBytes(), arrayOfInt, 1);
/* 376 */ StdQTException.checkError(i);
/* 377 */ FixedPt2DoublePt(arrayOfInt, paramQDPoint);
/* */ }
/* */
/* */ public void transformDPoints(QDPoint[] paramArrayOfQDPoint)
/* */ throws QTException
/* */ {
/* 386 */ int[] arrayOfInt = DoublePts2FixedPts(paramArrayOfQDPoint);
/* 387 */ int i = TransformFixedPoints(getBytes(), arrayOfInt, paramArrayOfQDPoint.length);
/* 388 */ StdQTException.checkError(i);
/* 389 */ FixedPts2DoublePts(arrayOfInt, paramArrayOfQDPoint);
/* */ }
/* */
/* */ public void transformPoints(QDPoint paramQDPoint)
/* */ throws StdQTException
/* */ {
/* 399 */ int[] arrayOfInt = new int[1];
/* 400 */ arrayOfInt[0] = ((paramQDPoint.getY() << 16) + paramQDPoint.getX());
/* */
/* 402 */ StdQTException.checkError(TransformPoints(getBytes(), arrayOfInt, 1));
/* */
/* 405 */ paramQDPoint.setY(arrayOfInt[0] >> 16);
/* 406 */ paramQDPoint.setX(arrayOfInt[0] & 0xFFFF);
/* */ }
/* */
/* */ public void transformPoints(QDPoint[] paramArrayOfQDPoint)
/* */ throws StdQTException
/* */ {
/* 416 */ int[] arrayOfInt = new int[paramArrayOfQDPoint.length];
/* 417 */ for (int i = 0; i < paramArrayOfQDPoint.length; i++) {
/* 418 */ arrayOfInt[i] = ((paramArrayOfQDPoint[i].getY() << 16) + paramArrayOfQDPoint[i].getX());
/* */ }
/* 420 */ StdQTException.checkError(TransformPoints(getBytes(), arrayOfInt, paramArrayOfQDPoint.length));
/* */
/* 423 */ for (i = 0; i < paramArrayOfQDPoint.length; i++) {
/* 424 */ paramArrayOfQDPoint[i].setY(arrayOfInt[i] >> 16);
/* 425 */ paramArrayOfQDPoint[i].setX(arrayOfInt[i] & 0xFFFF);
/* */ }
/* */ }
/* */
/* */ public boolean transformDRect(QDRect paramQDRect)
/* */ throws QTException
/* */ {
/* 437 */ if (paramQDRect.getFixedRect() == null) throw new QTException(-50);
/* 438 */ return TransformFixedRect(getBytes(), paramQDRect.getFixedRect(), 0) != 0;
/* */ }
/* */
/* */ public boolean transformDRect(QDRect paramQDRect, QDPoint[] paramArrayOfQDPoint)
/* */ throws QTException
/* */ {
/* 450 */ int[] arrayOfInt = DoublePts2FixedPts(paramArrayOfQDPoint);
/* */
/* 452 */ if (paramQDRect.getFixedRect() == null) throw new QTException(-50);
/* 453 */ int i = TransformFixedRect(getBytes(), paramQDRect.getFixedRect(), arrayOfInt);
/* 454 */ if (i == 0) FixedPts2DoublePts(arrayOfInt, paramArrayOfQDPoint);
/* */
/* 456 */ return i != 0;
/* */ }
/* */
/* */ public boolean transformRect(QDRect paramQDRect)
/* */ throws QTException
/* */ {
/* 466 */ return TransformRect(getBytes(), paramQDRect.getRect(), 0) != 0;
/* */ }
/* */
/* */ public boolean transformRect(QDRect paramQDRect, QDPoint[] paramArrayOfQDPoint)
/* */ throws QTException
/* */ {
/* 477 */ int[] arrayOfInt = DoublePts2FixedPts(paramArrayOfQDPoint);
/* 478 */ int i = TransformRect(getBytes(), paramQDRect.getRect(), arrayOfInt);
/* 479 */ if (i == 0) FixedPts2DoublePts(arrayOfInt, paramArrayOfQDPoint);
/* */
/* 481 */ return i != 0;
/* */ }
/* */
/* */ public void transformRgn(Region paramRegion)
/* */ throws StdQTException
/* */ {
/* 490 */ StdQTException.checkError(TransformRgn(getBytes(), QTObject.ID(paramRegion)));
/* */ }
/* */
/* */ public void rect(QDRect paramQDRect1, QDRect paramQDRect2)
/* */ {
/* 501 */ RectMatrix(getBytes(), paramQDRect1.getRect(), paramQDRect2.getRect());
/* */ }
/* */
/* */ public void map(QDRect paramQDRect1, QDRect paramQDRect2)
/* */ {
/* 512 */ MapMatrix(getBytes(), paramQDRect1.getRect(), paramQDRect2.getRect());
/* */ }
/* */
/* */ public String toString()
/* */ {
/* 529 */ return getClass().getName() + "[(" + Double.toString(getSx()) + ", " + Double.toString(getB()) + ", " + Double.toString(getU()) + "), (" + Double.toString(getC()) + ", " + Double.toString(getSy()) + ", " + Double.toString(getV()) + "), (" + Double.toString(getTx()) + ", " + Double.toString(getTy()) + ", " + Double.toString(getW()) + ")]";
/* */ }
/* */
/* */ public Matrix copy()
/* */ {
/* 547 */ return new Matrix(getBytes());
/* */ }
/* */
/* */ public Object clone()
/* */ {
/* 556 */ return copy();
/* */ }
/* */
/* */ public boolean equals(Matrix paramMatrix)
/* */ {
/* 566 */ return EqualMatrix(getBytes(), paramMatrix.getBytes()) != 0;
/* */ }
/* */
/* */ private static native short QuadToQuadMatrix(int[] paramArrayOfInt1, int[] paramArrayOfInt2, byte[] paramArrayOfByte);
/* */
/* */ private static native short GetMatrixType(byte[] paramArrayOfByte);
/* */
/* */ private static native void SetIdentityMatrix(byte[] paramArrayOfByte);
/* */
/* */ private static native void TranslateMatrix(byte[] paramArrayOfByte, int paramInt1, int paramInt2);
/* */
/* */ private static native void RotateMatrix(byte[] paramArrayOfByte, int paramInt1, int paramInt2, int paramInt3);
/* */
/* */ private static native void ScaleMatrix(byte[] paramArrayOfByte, int paramInt1, int paramInt2, int paramInt3, int paramInt4);
/* */
/* */ private static native void SkewMatrix(byte[] paramArrayOfByte, int paramInt1, int paramInt2, int paramInt3, int paramInt4);
/* */
/* */ private static native byte InverseMatrix(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2);
/* */
/* */ private static native void ConcatMatrix(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2);
/* */
/* */ private static native short TransformFixedPoints(byte[] paramArrayOfByte, int[] paramArrayOfInt, int paramInt);
/* */
/* */ private static native short TransformPoints(byte[] paramArrayOfByte, int[] paramArrayOfInt, int paramInt);
/* */
/* */ private static native byte TransformFixedRect(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2, int[] paramArrayOfInt);
/* */
/* */ private static native byte TransformFixedRect(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2, int paramInt);
/* */
/* */ private static native byte TransformRect(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2, int[] paramArrayOfInt);
/* */
/* */ private static native byte TransformRect(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2, int paramInt);
/* */
/* */ private static native short TransformRgn(byte[] paramArrayOfByte, int paramInt);
/* */
/* */ private static native void RectMatrix(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2, byte[] paramArrayOfByte3);
/* */
/* */ private static native void MapMatrix(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2, byte[] paramArrayOfByte3);
/* */
/* */ private static native void CopyMatrix(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2);
/* */
/* */ private static native byte EqualMatrix(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2);
/* */
/* */ private static native int getIntFromArray(byte[] paramArrayOfByte, int paramInt);
/* */
/* */ private static native void setIntInArray(byte[] paramArrayOfByte, int paramInt1, int paramInt2);
/* */ }
/* Location: Z:\System\Library\Java\Extensions\QTJava.zip
* Qualified Name: quicktime.std.image.Matrix
* JD-Core Version: 0.6.2
*/