[dad864]: mos.h  Maximize  Restore  History

Download this file

191 lines (174 with data), 6.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
// mos.h: interface for the Cmos class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_MOS_H__143AC7EF_EC59_436A_8AA9_E17B960DBE01__INCLUDED_)
#define AFX_MOS_H__143AC7EF_EC59_436A_8AA9_E17B960DBE01__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "structs.h"
class INF_MOS_FRAMEDATA
{
public:
palettetype Palette;
BYTE *pFrameData;
int nFrameSize;
DWORD nWidth, nHeight;
INF_MOS_FRAMEDATA()
{
pFrameData=NULL;
nFrameSize=0;
memset(&Palette,0,sizeof(Palette) );
}
~INF_MOS_FRAMEDATA()
{
if(pFrameData)
{
delete [] pFrameData;
pFrameData=NULL;
nFrameSize=0;
}
}
void OrderPalette();
void AlterPalette(int r, int g, int b, int strength);
void ReorderPixels();
void MarkPixels();
void MovePixels(BYTE chFrom, BYTE chTo);
bool IsTransparent(DWORD x, DWORD y);
int TakeMosData(const BYTE *pRawBits, DWORD width, DWORD height, bool deepen=false);
int ReducePalette(int treshold, int bestcolor, COLORREF newcolor, int index);
int FindBestColor(COLORREF mycolor, int &difference);
int FindColor(COLORREF mycolor, int palettesize);
DWORD GetColor(int x, int y);
int TakeWholeBmpData(const COLORREF *pRawBits);
int TakePaletteData(const BYTE *pRawBits);
int TakeBmpData(const BYTE *pRawBits, int row, int offset);
bool ExpandMosBitsWhole(COLORREF clrReplace, COLORREF clrTransparent, COLORREF *pDIBits, int nOffset, int wWidth);
int ExpandMosLine(char *pBuffer, int nSourceOff);
int SaturateTransparency();
void AllocateTransparency();
void FlipTile();
};
typedef CMap<COLORREF, COLORREF&, int, int&> CPaletteMap;
typedef CList<INF_MOS_FRAMEDATA *, INF_MOS_FRAMEDATA *> CFrameList;
class Cmos
{
public:
Cmos();
virtual ~Cmos();
wed_tilemap *m_tileheaders;
short *m_tileindices;
CString m_name;
int m_nQualityLoss;
INF_MOS_HEADER mosheader;
INF_MOS2_HEADER mosheader2;
tis_header tisheader;
BOOL m_bCompressed;
BOOL m_pvr;
DWORD *m_pOffsets;
int m_overlay;
int m_overlaytile;
Cmos *m_friend[10];
bool m_changed;
bool m_drawclosed;
int m_pixelwidth, m_pixelheight;
INF_MOS_FRAMEDATA *GetFrameData(DWORD nFrameWanted);
bool MosChanged() { return m_changed; }
void FreeOverlay();
void SetTiles(wed_tilemap *tileheaders, short *tileindices);
void SetOverlay(int overlay, Cmos *overlaymos);
int ResolveFrameNumber(int framenumber);
void new_mos();
void DropUnusedPalette();
void ApplyPaletteRGBTile(int nFrameWanted, int r, int g, int b, int strength);
void ApplyPaletteRGB(int r, int g, int b, int strength);
int RetrieveTisFrameCount(int fhandle, loc_entry *fl);
int GetFrameCount();
CPoint GetFrameSize(DWORD nFrame);
unsigned char *GetFrameBuffer(DWORD nFrame);
COLORREF GetPixelData(int x, int y);
int TakeOneFrame(DWORD nFrameWanted, COLORREF *prFrameBuffer, int factor);
unsigned long *GetFramePalette(DWORD nFrame);
bool MakeBitmap(COLORREF clrTrans, Cmos &host, int nMode, int nXpos, int nYpos);
bool MakeBitmapWhole(COLORREF clrTrans, HBITMAP &hBitmap, int clipx, int clipy, int maxclipx, int maxclipy, bool norender);
int MakeTransparent(DWORD nFrame, DWORD redgreenblue, int limit);
int ReadBmpFromFile(int fhandle, int ml);
int WriteMosToBmpFile(int fhandle, int clipx=0, int clipy=0,int maxclipx=-1, int maxclipy=-1);
int WriteTisToBmpFile(int fhandle, int clipx=0, int clipy=0,int maxclipx=-1, int maxclipy=-1);
int WriteMosToFile(int fhandle);
//int WritePvrToFile(int fhandle, int clipx=0, int clipy=0, int maxclipx=-1, int maxclipy=-1);
int WriteTisToFile(int fhandle, int clipx=0, int clipy=0, int maxclipx=-1, int maxclipy=-1);
int ReadMosFromFile(int fhandle, int maxlen);
int ReadTisFromFile(int fhandle, loc_entry *fl, bool header, bool preview);
void SetTisParameters(loc_entry *fl, int size);
int TisToMos(DWORD x, DWORD y);
int Allocate(DWORD x, DWORD y);
int GetImageWidth(int clipx, int maxclipx);
int GetImageHeight(int clipy, int maxclipy);
DWORD GetColor(DWORD x, DWORD y);
int FlipTile(DWORD nFrameWanted);
int RemoveTile(DWORD tile);
//flags = 1 deepen, 2 = empty tile
int AddTileCopy(DWORD original, unsigned char *optionalpixels = NULL, int flags=0);
int SetFrameData(DWORD nFrameWanted, INF_MOS_FRAMEDATA *oldframe);
int SaturateTransparency(DWORD tile, bool createcopy = false, bool deepen=false);
inline int GetDataSize()
{
return m_nDataSize;
}
inline void KillData()
{
if(m_pData)
{
delete [] m_pData;
m_pData=NULL;
}
}
inline void KillFrameData()
{
POSITION pos=m_pFrameData.GetHeadPosition();
while(pos)
{
INF_MOS_FRAMEDATA *p=m_pFrameData.GetNext(pos);
if(p) delete p;
}
m_pFrameData.RemoveAll();
if(m_pFrameDataPointer)
{
free(m_pFrameDataPointer);
m_pFrameDataPointer=NULL;
}
tisheader.numtiles=0;
}
inline void KillOffsets()
{
if(m_pOffsets)
{
delete [] m_pOffsets;
m_pOffsets=NULL;
}
}
inline COLORREF *GetDIB() { return m_pclrDIBits; }
inline int GetDIBsize() { return m_DIBsize; }
private:
COLORREF *m_pclrDIBits;
INF_MOSC_HEADER c_header;
BYTE *m_pData; //uncompressed/raw mos data
DWORD m_nDataSize; //uncompressed/raw mos data size (sizeof m_pData)
DWORD fullsize;
int m_nResX, m_nResY;
INF_MOS_FRAMEDATA **m_pFrameDataPointer; //pointer array for individual frames
CFrameList m_pFrameData;
int m_DIBsize;
bool CreateFrames();
int ExplodeMosData(int fhandle);
int ImplodeMosData();
int ReducePalette(int fhandle, bmp_header &sHeader, LPBYTE pcBuffer,
DWORD scanline, DWORD nSourceOff);
int CollectFrameData(int fhandle, DWORD *prFrameBuffer, LPBYTE pcBuffer,
DWORD height, DWORD scanline, DWORD nFrameCol,
DWORD cols, DWORD rows);
int GetFrameData(DWORD *prFrameBuffer, LPBYTE pRawData, DWORD height,
DWORD scanline, DWORD nFrameCol, DWORD cols, DWORD rows);
};
#endif // !defined(AFX_MOS_H__143AC7EF_EC59_436A_8AA9_E17B960DBE01__INCLUDED_)

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks