ch_oV2M9jra6Fo8iAguZpOOq2)(mech_jhfUsXlmtbQCjgnBc4yiw0 *,real_T *
,boolean_T);boolean_T(*mech_PzjukPSCeO9ZIgp3gH_kH0)(
mech_jhfUsXlmtbQCjgnBc4yiw0 *);boolean_T(*mech_kJBexodzYnsEiQjpmVtWK2)(
mech_jhfUsXlmtbQCjgnBc4yiw0 *);boolean_T(*mech_VPioDZqYpfCwM5K09Feml_)(
mech_jhfUsXlmtbQCjgnBc4yiw0 *,real_T *,real_T *,boolean_T);void(*
mech_8_OU8d_0ZTQbTXIXHHpZa0)(mech_jhfUsXlmtbQCjgnBc4yiw0 *,real_T *);
mech__gelu9Rg33zO26z2_C7EP1 *mech_0eUXp6_qy00yiG66C_S6o0;
mech_kOZjPLpZX2UWXYk3ZjK2P1 *mech_fiH8H_DAYlabFwkR4viRK2;const void *
mech_nMjPZcof0YYlsZQIdpFDw1;};typedef struct mech_BqxCXIJyizuUke4ju1B6c1{
int32_T mech_EYX9_VfSnff0TqLkRZk251;int32_T mech_IJrXRCPLJ8aQsV3wu1K6q0;
int32_T mech_NjHJaZ_EGuOFhVlPpcAO70;}mech_WNDuEMpvoOrdlX7ruXNzP0;typedef enum
mech_LNjB0cAWuuQVXpX1uwcoc_{mech_xwDVV84z6QLje0T0xBD3T0,
mech_b39ddDbOBulibRdBOJBSN2,mech_NkRd2pEr0ARhSTRln7XYO2}
mech_TySa6gXIcQVafcmlgN0V81;struct mech_LnN15eUbsciBp96d7XeIi1{real_T *
mech_1rg5Osg1YqZjr7xO6cmlv0;real_T *mech__C4osuKafjRC35il8VstV_;int32_T
mech_bRDjZ7FGS9h246ivFgr_Q2;int32_T mech__bhl5C2HyE0LLZbUxnbxq2;int32_T
mech_Gcb5Mif1ibg27w7Hg3LxE2;int32_T mech_JfK0Ad28WxxKW7pR4sFrt_;
mech_TySa6gXIcQVafcmlgN0V81 mech_kdc47pnwqhpH_MmmYSZN20;};struct
mech_eC90bw0lz5wSxflYEVMiC_{int32_T mech_g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uLG3a_Uv3ZUmJXHe4Ie_ *mech_4tBbiLLZTRN_gySQp_OOe1;
mech_iIuLG3a_Uv3ZUmJXHe4Ie_ *mech_GstBZ1q6l8t80AgoronUF2;
mech_iIuLG3a_Uv3ZUmJXHe4Ie_ *mech_AwCAySrk6b9kt1nQZiCEP2;};struct
mech_7NMBu_YdM1pGI29_wf2ge2{int32_T mech_fPgaeycTyLjik1O5OpdDP2;int32_T
mech_wlBPBr1ezkgqp1dOY_wQC2;mech_iIuLG3a_Uv3ZUmJXHe4Ie_ *
mech_1rg5Osg1YqZjr7xO6cmlv0;mech_iIuLG3a_Uv3ZUmJXHe4Ie_ *
mech_pEdesk_1gHwuHKHB74pmT0;mech_iIuLG3a_Uv3ZUmJXHe4Ie_ *
mech_1o_d7E6W_3RQ3_R1UYbz__;mech_iIuLG3a_Uv3ZUmJXHe4Ie_ *
mech_F80VmlV2pXEaolBwUE1oT_;mech_iIuLG3a_Uv3ZUmJXHe4Ie_ *
mech_xrkB_NcJfULWPBS6JPaOM2;mech_iIuLG3a_Uv3ZUmJXHe4Ie_ *
mech_4SnHJSxdNxYHFmuReEkVK1;void *mech_pmheAdoDwoBQd4KcDH5sQ2;};struct
mech_7w846MGHbgq3wjxnIVdiz_{mech_iIuLG3a_Uv3ZU/**************************************************************************\
* 
* Copyright (c) 1998-2001, Microsoft Corp.  All Rights Reserved.
*
* Module Name:
*
*   GdiplusMatrix.h
*
* Abstract:
*
*   GDI+ Matrix class
*
\**************************************************************************/

#include <winapifamily.h>

#pragma region Desktop Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)

#if _MSC_VER >= 1200
#pragma warning(push)
#pragma warning(disable:4820) /* padding added after data member */
#endif

class Matrix : public GdiplusBase
{
public:
    friend class Graphics;
    friend class GraphicsPath;
    friend class TextureBrush;
    friend class LinearGradientBrush;
    friend class PathGradientBrush;
    friend class Pen;
    friend class Region;
    
    // Default constructor is set to identity matrix.

    Matrix()
    {
        GpMatrix *matrix = NULL;

        lastResult = DllExports::GdipCreateMatrix(&matrix);
    
        SetNativeMatrix(matrix);
    }

    Matrix(IN REAL m11, 
           IN REAL m12,
           IN REAL m21, 
           IN REAL m22,
           IN REAL dx, 
           IN REAL dy)
    {
        GpMatrix *matrix = NULL;

        lastResult = DllExports::GdipCreateMatrix2(m11, m12, m21, m22, 
                                                      dx, dy, &matrix);
    
        SetNativeMatrix(matrix);
    }
    
    Matrix(IN const RectF& rect, 
           IN const PointF* dstplg)
    {
        GpMatrix *matrix = NULL;

        lastResult = DllExports::GdipCreateMatrix3(&rect, 
                                                   dstplg,
                                                   &matrix);

        SetNativeMatrix(matrix);
    }

    Matrix(IN const Rect& rect, 
           IN const Point* dstplg)
    {
        GpMatrix *matrix = NULL;

        lastResult = DllExports::GdipCreateMatrix3I(&rect, 
                                                    dstplg,
                                                    &matrix);

        SetNativeMatrix(matrix);
    }

    ~Matrix()
    {
        DllExports::GdipDeleteMatrix(nativeMatrix);
    }

    Matrix *Clone() const
    {
        GpMatrix *cloneMatrix = NULL;

        SetStatus(DllExports::GdipCloneMatrix(nativeMatrix,
                                                  &cloneMatrix));

        if (lastResult != Ok)
            return NULL;

        return new Matrix(cloneMatrix);
    }

    Status GetElements(OUT REAL *m) const 
    {
        return SetStatus(DllExports::GdipGetMatrixElements(nativeMatrix, m));
    }
    
    Status SetElements(IN REAL m11, 
                       IN REAL m12, 
                       IN REAL m21, 
                       IN REAL m22, 
                       IN REAL dx, 
                       IN REAL dy)
    {
        return SetStatus(DllExports::GdipSetMatrixElements(nativeMatrix,
                            m11, m12, m21, m22, dx, dy));
    }

    REAL OffsetX() const
    {
        REAL elements[6];

        if (GetElements(&elements[0]) == Ok)
            return elements[4];
        else 
            return 0.0f;
    }

    REAL OffsetY() const
    {
       REAL elements[6];

       if (GetElements(&elements[0]) == Ok)
           return elements[5];
       else 
           return 0.0f;
    }

    Status Reset()
    {
        // set identity matrix elements 
        return SetStatus(DllExports::GdipSetMatrixElements(nativeMatrix,
                                             1.0, 0.0, 0.0, 1.0, 0.0, 0.0));
    }

    Status Multiply(IN const Matrix *matrix, 
                    IN MatrixOrder order = MatrixOrderPrepend)
    {
        return SetStatus(DllExports::GdipMultiplyMatrix(nativeMatrix, 
                                          matrix->nativeMatrix,
                                          order));
    }

    Status Translate(IN REAL offsetX, 
                     IN REAL offsetY, 
                     IN MatrixOrder order = MatrixOrderPrepend)
    {
        return SetStatus(DllExports::GdipTranslateMatrix(nativeMatrix, offsetX,
                                                         offsetY, order));
    }

    Status Scale(IN REAL scaleX, 
                 IN REAL scaleY, 
                 IN MatrixOrder order = MatrixOrderPrepend)
    {
        return SetStatus(DllExports::GdipScaleMatrix(nativeMatrix, scaleX, 
                                                     scaleY, order));
    }

    Status Rotate(IN REAL angle, 
                  IN MatrixOrder order = MatrixOrderPrepend)
    {
        return SetStatus(DllExports::GdipRotateMatrix(nativeMatrix, angle, 
                                                      order));
    }
    
    Status RotateAt(IN REAL angle, 
                    IN const PointF& center, 
                    IN MatrixOrder order = MatrixOrderPrepend)
    {
        if(order == MatrixOrderPrepend)
        {
            SetStatus(DllExports::GdipTranslateMatrix(nativeMatrix, center.X,
                                                      center.Y, order));
            SetStatus(DllExports::GdipRotateMatrix(nativeMatrix, angle, 
                                                   order));
            return SetStatus(DllExports::GdipTranslateMatrix(nativeMatrix,
                                                             -center.X, 
                                                             -center.Y, 
                                                             order));
        }
        else
        {
            SetStatus(DllExports::GdipTranslateMatrix(nativeMatrix, 
                                                      - center.X, 
                                                      - center.Y, 
                                                      order));
            SetStatus(DllExports::GdipRotateMatrix(nativeMatrix, angle, 
                                                   order));
            return SetStatus(DllExports::GdipTranslateMatrix(nativeMatrix, 
                                                             center.X, 
                                                             center.Y, 
                                                             order));
        }
    }

    Status Shear(IN REAL shearX, 
                 IN REAL shearY,
                 IN MatrixOrder order = MatrixOrderPrepend)
    {
        return SetStatus(DllExports::GdipShearMatrix(nativeMatrix, shearX, 
                                                     shearY, order));
    }

    Status Invert()
    {
        return SetStatus(DllExports::GdipInvertMatrix(nativeMatrix));
    }

    // float version
    Status TransformPoints(IN OUT PointF* pts, 
                           IN INT count = 1) const
    {
        return SetStatus(DllExports::GdipTransformMatrixPoints(nativeMatrix, 
                                                               pts, count));
    }
    
    Status TransformPoints(IN OUT Point* pts, 
                           IN INT count = 1) const
    {
        return SetStatus(DllExports::GdipTransformMatrixPointsI(nativeMatrix, 
                                                                pts, 
                                                                count));
    }

    Status TransformVectors(IN OUT PointF* pts, 
                            IN INT count = 1) const
    { 
        return SetStatus(DllExports::GdipVectorTransformMatrixPoints(
                                        nativeMatrix, pts, count));
    }

    Status TransformVectors(IN OUT Point* pts, 
                            IN INT count = 1) const
    { 
       return SetStatus(DllExports::GdipVectorTransformMatrixPointsI(
                                        nativeMatrix, 
                                        pts, 
                                        count));
    }
    
    BOOL IsInvertible() const
    {
        BOOL result = FALSE;

        SetStatus(DllExports::GdipIsMatrixInvertible(nativeMatrix, &result));
    
        return result;
    }

    BOOL IsIdentity() const
    {
       BOOL result = FALSE;

       SetStatus(DllExports::GdipIsMatrixIdentity(nativeMatrix, &result));
    
       return result;
    }

    BOOL Equals(IN const Matrix *matrix) const
    {
       BOOL result = FALSE;

       SetStatus(DllExports::GdipIsMatrixEqual(nativeMatrix,
                                               matrix->nativeMatrix, 
                                               &result));
   
       return result;
    }
    
    Status GetLastStatus() const
    {
        Status lastStatus = lastResult;
        lastResult = Ok;
 
        return lastStatus;
    }

private:
    Matrix(const Matrix &);
    Matrix& operator=(const Matrix &);

protected:
    Matrix(GpMatrix *nativeMatrix)
    {
        lastResult = Ok;
        SetNativeMatrix(nativeMatrix);
    }
    
    VOID SetNativeMatrix(GpMatrix *nativeMatrix)
    {
        this->nativeMatrix = nativeMatrix;
    }

    Status SetStatus(Status status) const
    {
        if (status != Ok)
            return (lastResult = status);
        else
            return status;
    }

protected:
    GpMatrix *nativeMatrix;
    mutable Status lastResult;
};

#if _MSC_VER >= 1200
#pragma warning(pop)
#endif

#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
#pragma endregion

