Subversion Repositories AndroidProjects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
244 chris 1
#ifndef __IMAGE_H__
2
#define __IMAGE_H__
3
 
4
#include "Common.h"
5
#include "Color.h"
6
#include "Rect.h"
7
#include "Point.h"
8
 
9
namespace Sexy
10
{
11
 
12
struct Span
13
{
14
        int                                             mY;
15
        int                                             mX;
16
        int                                             mWidth;
17
};
18
 
19
enum AnimType
20
{
21
        AnimType_None,
22
        AnimType_Once,
23
        AnimType_PingPong,
24
        AnimType_Loop
25
};
26
 
27
struct AnimInfo
28
{
29
        AnimType                                mAnimType;
30
        int                                             mFrameDelay; // 1/100s
31
        int                                             mNumCels;
32
        std::vector<int>                mPerFrameDelay;
33
        std::vector<int>                mFrameMap;
34
        int                                             mTotalAnimTime;
35
 
36
        AnimInfo();
37
        void SetPerFrameDelay(int theFrame, int theTime);
38
        void Compute(int theNumCels, int theBeginFrameTime = 0, int theEndFrameTime = 0);
39
 
40
        int GetPerFrameCel(int theTime);
41
        int GetCel(int theTime);
42
};
43
 
44
class Graphics;
45
class SexyMatrix3;
46
class SysFont;
47
class TriVertex;
48
 
49
class Image
50
{
51
        friend class                    Sexy::SysFont;
52
 
53
public:
54
        bool                                    mDrawn;
55
        std::string                             mFilePath;
56
        int                                             mWidth;
57
        int                                             mHeight;
58
 
59
        // for image strips
60
        int                                             mNumRows;
61
        int                                             mNumCols;
62
 
63
        // for animations
64
        AnimInfo                                *mAnimInfo;
65
 
66
public:
67
        Image();
68
        Image(const Image& theImage);
69
        virtual ~Image();
70
 
71
        int                                             GetWidth();
72
        int                                             GetHeight();
73
        int                                             GetCelWidth();          // returns the width of just 1 cel in a strip of images
74
        int                                             GetCelHeight(); // like above but for vertical strips
75
        int                                             GetAnimCel(int theTime); // use animinfo to return appropriate cel to draw at the time
76
        Rect                                    GetAnimCelRect(int theTime);
77
        Rect                                    GetCelRect(int theCel);                         // Gets the rectangle for the given cel at the specified row/col 
78
        Rect                                    GetCelRect(int theCol, int theRow);     // Same as above, but for an image with both multiple rows and cols
79
        void                                    CopyAttributes(Image *from);
80
        Graphics*                               GetGraphics();
81
 
82
        virtual bool                    PolyFill3D(const Point theVertices[], int theNumVertices, const Rect *theClipRect, const Color &theColor, int theDrawMode, int tx, int ty, bool convex);
83
 
84
        virtual void                    FillRect(const Rect& theRect, const Color& theColor, int theDrawMode); 
85
        virtual void                    DrawRect(const Rect& theRect, const Color& theColor, int theDrawMode);
86
        virtual void                    ClearRect(const Rect& theRect);
87
        virtual void                    DrawLine(double theStartX, double theStartY, double theEndX, double theEndY, const Color& theColor, int theDrawMode);
88
        virtual void                    DrawLineAA(double theStartX, double theStartY, double theEndX, double theEndY, const Color& theColor, int theDrawMode);
89
        virtual void                    FillScanLines(Span* theSpans, int theSpanCount, const Color& theColor, int theDrawMode);
90
        virtual void                    FillScanLinesWithCoverage(Span* theSpans, int theSpanCount, const Color& theColor, int theDrawMode, const BYTE* theCoverage, int theCoverX, int theCoverY, int theCoverWidth, int theCoverHeight);
91
        virtual void                    Blt(Image* theImage, int theX, int theY, const Rect& theSrcRect, const Color& theColor, int theDrawMode);
92
        virtual void                    BltF(Image* theImage, float theX, float theY, const Rect& theSrcRect, const Rect &theClipRect, const Color& theColor, int theDrawMode);
93
        virtual void                    BltRotated(Image* theImage, float theX, float theY, const Rect &theSrcRect, const Rect& theClipRect, const Color& theColor, int theDrawMode, double theRot, float theRotCenterX, float theRotCenterY);
94
        virtual void                    StretchBlt(Image* theImage, const Rect& theDestRect, const Rect& theSrcRect, const Rect& theClipRect, const Color& theColor, int theDrawMode, bool fastStretch);
95
        virtual void                    BltMatrix(Image* theImage, float x, float y, const SexyMatrix3 &theMatrix, const Rect& theClipRect, const Color& theColor, int theDrawMode, const Rect &theSrcRect, bool blend);
96
        virtual void                    BltTrianglesTex(Image *theTexture, const TriVertex theVertices[][3], int theNumTriangles, const Rect& theClipRect, const Color &theColor, int theDrawMode, float tx, float ty, bool blend);
97
 
98
        virtual void                    BltMirror(Image* theImage, int theX, int theY, const Rect& theSrcRect, const Color& theColor, int theDrawMode);
99
        virtual void                    StretchBltMirror(Image* theImage, const Rect& theDestRect, const Rect& theSrcRect, const Rect& theClipRect, const Color& theColor, int theDrawMode, bool fastStretch);
100
};
101
 
102
}
103
 
104
#endif //__IMAGE_H__