- GBPSLib compiles now with the final filestrutcure of G3D
[genesis3d.git] / G3D / Bitmap.__h
1 #ifndef GE_BITMAP____H\r
2 #define GE_BITMAP____H\r
3 \r
4 /****************************************************************************************/\r
5 /*  Bitmap.__h                                                                          */\r
6 /*                                                                                      */\r
7 /*  Author: Charles Bloom                                                               */\r
8 /*  Description:  Bitmap*.c Internal Header (contains the Bitmap Struct)                */\r
9 /*                                                                                      */\r
10 /*  The contents of this file are subject to the Genesis3D Public License               */\r
11 /*  Version 1.01 (the "License"); you may not use this file except in                   */\r
12 /*  compliance with the License. You may obtain a copy of the License at                */\r
13 /*  http://www.genesis3d.com                                                            */\r
14 /*                                                                                      */\r
15 /*  Software distributed under the License is distributed on an "AS IS"                 */\r
16 /*  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See                */\r
17 /*  the License for the specific language governing rights and limitations              */\r
18 /*  under the License.                                                                  */\r
19 /*                                                                                      */\r
20 /*  The Original Code is Genesis3D, released March 25, 1999.                            */\r
21 /*  Copyright (C) 1999 WildTangent, Inc. All Rights Reserved           */\r
22 /*                                                                                      */\r
23 /****************************************************************************************/\r
24 \r
25 #include "Bitmap.h"\r
26 #include "Bitmap._h"\r
27 \r
28 // Hey ! \r
29 // this is bitmap.__h : for inclusion by bitmap friends ONLY!\r
30 //      included by bitmap.c , bitmap_blitdata.c\r
31 \r
32 /*}{ *********** the bitmap type *******************/\r
33 \r
34 // the Version Major indicates an incompatibility\r
35 \r
36 #define GEBM_VERSION_MAJOR              (0x0004)\r
37 #define GEBM_VERSION_MINOR              (0x0000)\r
38 \r
39 #define MAXMIPLEVELS                    (8)\r
40 \r
41 #define PALETTE_FORMAT_DEFAULT  (GE_PIXELFORMAT_24BIT_RGB)\r
42 \r
43 #define ALPHA_TO_TRANSPARENCY_THRESHOLD         (80)\r
44 \r
45 struct geBitmap_Palette\r
46 {\r
47         int                             LockCount,RefCount;\r
48         gePixelFormat   Format;\r
49         int                             Size;\r
50         geBoolean               HasColorKey;\r
51         uint32                  ColorKey;               // the color which is the colorkey\r
52         int                             ColorKeyIndex;  // the palette index which is the color;\r
53                                                                         // Bitmap->CK == Bitmap->Pal->CK_Index\r
54 \r
55         // we have EITHER Data or DriverHandle\r
56         void                    *Data;          //Size * BytesPerPixel(Format)\r
57         DRV_Driver              *Driver;\r
58         geRDriver_THandle*DriverHandle;\r
59         void                    *DriverBits;    //only non-null inside a Lock/UnLock\r
60 };\r
61 \r
62 struct geBitmap\r
63 {\r
64         int                             RefCount;\r
65         geBitmap_Info           Info;\r
66         void *                          Data[MAXMIPLEVELS];\r
67         geBoolean                       Modified[MAXMIPLEVELS];\r
68                                                         // modified tells whether a mip != a scaledown of mip 0\r
69                                                         // modified[0] is ignored\r
70         geBitmap *                      Alpha;\r
71 \r
72         int                                     LockCount;      // -Nmips for 'write' , > 0 for 'read's\r
73         geBitmap *                      LockOwner;      // this points to our owner and doubles as boolean 'islocked'\r
74         geBitmap *                      DataOwner;      // if this is set, then my Data is not mine to free\r
75 \r
76         gePixelFormat           PreferredFormat;        // user's favorite\r
77         int                                     SeekMipCount;           // when we attach to driver, ask for this many mips\r
78 \r
79                 // must support any number of locks for read\r
80                 // a lock for read can be a pointer to my raw bits, or a whole different bitmap\r
81 \r
82         geBitmap_Info           DriverInfo;                     // all the driver mess..\r
83         uint32                          DriverFlags;\r
84         DRV_Driver *            Driver;\r
85         geRDriver_THandle *     DriverHandle;\r
86         int                                     DriverMipLock;          // which mip to lock on GetBits\r
87         geBoolean                       DriverBitsLocked;\r
88         geBoolean                       DriverDataChanged;      // relative to system copy\r
89         geFloat                         DriverGamma;\r
90         geFloat                         DriverGammaLast;\r
91         geBoolean                       DriverGammaSet;\r
92 };\r
93 \r
94 \r
95 /*}{ ************* internal protos *****************/\r
96 \r
97 //geBitmap * geBitmap_CreateXerox(geBitmap *BmpSrc);\r
98 \r
99 geBoolean geBitmap_IsValid(const geBitmap *Bmp);\r
100 geBoolean geBitmap_Info_IsValid(const geBitmap_Info *Info);\r
101 geBoolean geBitmap_Palette_IsValid(const geBitmap_Palette *Pal);\r
102 \r
103 geBoolean geBitmap_BlitMipRect(const geBitmap * Src, int SrcMip, int SrcX,int SrcY,\r
104                                                                          geBitmap * Dst, int DstMip, int DstX,int DstY,\r
105                                                         int SizeX,int SizeY);\r
106 \r
107 geBitmap * geBitmap_CreateLock_CopyInfo(geBitmap *BmpSrc,int LockCnt,int mip);\r
108 geBitmap * geBitmap_CreateLockFromMip(geBitmap *Src,int mip,\r
109         gePixelFormat Format,geBoolean HasColorKey,uint32 ColorKey,int LockCnt);\r
110 geBitmap * geBitmap_CreateLockFromMipSystem(geBitmap *Src,int mip,int LockCnt);\r
111 geBitmap * geBitmap_CreateLockFromMipOnDriver(geBitmap *Src,int mip,int LockCnt);\r
112 \r
113 geBoolean geBitmap_UnLock_NoChange(geBitmap *Bmp);\r
114 geBoolean geBitmap_UnLockArray_NoChange(geBitmap **Locks,int Size);\r
115 \r
116 geBoolean geBitmap_Update_SystemToDriver(geBitmap *Bmp);\r
117 geBoolean geBitmap_Update_DriverToSystem(geBitmap *Bmp);\r
118 \r
119 geBoolean geBitmap_MakeSystemMips(geBitmap *Bmp,int low,int high);\r
120 geBoolean geBitmap_UpdateMips_Data(     geBitmap_Info * FmInfo,void * FmBits,\r
121                                                                         geBitmap_Info * ToInfo,void * ToBits);\r
122 geBoolean geBitmap_UpdateMips_System(geBitmap *Bmp,int fm,int to);\r
123 \r
124 geBoolean geBitmap_UsesColorKey(const geBitmap * Bmp);\r
125 \r
126 void      geBitmap_MakeMipInfo(  geBitmap_Info *Src,int mip,geBitmap_Info *Into);\r
127 geBoolean geBitmap_MakeDriverLockInfo(geBitmap *Bmp,int mip,geBitmap_Info *Into);\r
128                                         // MakeDriverLockInfo also doesn't full out the full info, so it must be a valid info first!\r
129                                         // Bmp also gets some crap written into him.\r
130 \r
131 geBoolean geBitmap_AllocSystemMip(geBitmap *Bmp,int mip);\r
132 geBoolean geBitmap_AllocPalette(geBitmap *Bmp,gePixelFormat Format,DRV_Driver * Driver);\r
133 \r
134 geBoolean geBitmap_ReadInfo( geBitmap *Bmp,geVFile * F);\r
135 geBoolean geBitmap_WriteInfo(const geBitmap *Bmp,geVFile * F);\r
136 \r
137 geBoolean geBitmap_FixDriverFlags(uint32 *pFlags);\r
138 \r
139 /*}{ ************* end *****************/\r
140 \r
141 #endif\r