Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Bitmap.h
Go to the documentation of this file.
1
/* Project nGenEx
2
Destroyer Studios LLC
3
Copyright © 1997-2004. All Rights Reserved.
4
5
SUBSYSTEM: nGenEx.lib
6
FILE: Bitmap.h
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
Bitmap Resource class
13
*/
14
15
#ifndef Bitmap_h
16
#define Bitmap_h
17
18
#include "
Res.h
"
19
#include "
Types.h
"
20
#include "
Geometry.h
"
21
22
// +--------------------------------------------------------------------+
23
24
class
Color
;
25
class
ColorIndex
;
26
27
class
Bitmap
:
public
Resource
28
{
29
public
:
30
static
const
char
*
TYPENAME
() {
return
"Bitmap"
; }
31
32
enum
BMP_TYPES
{
BMP_SOLID
,
BMP_TRANSPARENT
,
BMP_TRANSLUCENT
};
33
34
Bitmap
();
35
Bitmap
(
int
w,
int
h,
ColorIndex
* p=0,
int
t=
BMP_SOLID
);
36
Bitmap
(
int
w,
int
h,
Color
* p,
int
t=
BMP_SOLID
);
37
virtual
~Bitmap
();
38
39
int
IsIndexed
()
const
{
return
pix
!= 0; }
40
int
IsHighColor
()
const
{
return
hipix
!= 0; }
41
int
IsDual
()
const
{
return
IsIndexed
() &&
42
IsHighColor
(); }
43
44
void
SetType
(
int
t) {
type
= t; }
45
int
Type
()
const
{
return
type
; }
46
bool
IsSolid
()
const
{
return
type
==
BMP_SOLID
; }
47
bool
IsTransparent
()
const
{
return
type
==
BMP_TRANSPARENT
; }
48
bool
IsTranslucent
()
const
{
return
type
==
BMP_TRANSLUCENT
; }
49
50
int
Width
()
const
{
return
width
; }
51
int
Height
()
const
{
return
height
; }
52
ColorIndex
*
Pixels
()
const
{
return
pix
; }
53
Color
*
HiPixels
()
const
{
return
hipix
; }
54
int
BmpSize
()
const
;
55
int
RowSize
()
const
;
56
57
ColorIndex
GetIndex
(
int
x,
int
y)
const
;
58
Color
GetColor
(
int
x,
int
y)
const
;
59
void
SetIndex
(
int
x,
int
y,
ColorIndex
c);
60
void
SetColor
(
int
x,
int
y,
Color
c);
61
62
void
FillColor
(
Color
c);
63
64
void
ClearImage
();
65
void
BitBlt
(
int
x,
int
y,
const
Bitmap
& srcImage,
int
sx,
int
sy,
int
w,
int
h,
bool
blend=
false
);
66
void
CopyBitmap
(
const
Bitmap
& rhs);
67
void
CopyImage
(
int
w,
int
h, BYTE* p,
int
t=
BMP_SOLID
);
68
void
CopyHighColorImage
(
int
w,
int
h, DWORD* p,
int
t=
BMP_SOLID
);
69
void
CopyAlphaImage
(
int
w,
int
h, BYTE* p);
70
void
CopyAlphaRedChannel
(
int
w,
int
h, DWORD* p);
71
void
AutoMask
(DWORD mask=0);
72
73
virtual
BYTE*
GetSurface
();
74
virtual
int
Pitch
()
const
;
75
virtual
int
PixSize
()
const
;
76
bool
ClipLine
(
int
& x1,
int
& y1,
int
& x2,
int
& y2);
77
bool
ClipLine
(
double
& x1,
double
& y1,
double
& x2,
double
& y2);
78
void
DrawLine
(
int
x1,
int
y1,
int
x2,
int
y2,
Color
color);
79
void
DrawRect
(
int
x1,
int
y1,
int
x2,
int
y2,
Color
color);
80
void
DrawRect
(
const
Rect
& r,
Color
color);
81
void
FillRect
(
int
x1,
int
y1,
int
x2,
int
y2,
Color
color);
82
void
FillRect
(
const
Rect
& r,
Color
color);
83
void
DrawEllipse
(
int
x1,
int
y1,
int
x2,
int
y2,
Color
color, BYTE quad=0x0f);
84
void
DrawEllipsePoints
(
int
x0,
int
y0,
int
x,
int
y,
Color
c, BYTE quad);
85
86
void
ScaleTo
(
int
w,
int
h);
87
void
MakeIndexed
();
88
void
MakeHighColor
();
89
void
MakeTexture
();
90
bool
IsTexture
()
const
{
return
texture
; }
91
void
TakeOwnership
() {
ownpix
=
true
; }
92
93
const
char
*
GetFilename
()
const
{
return
filename
; }
94
void
SetFilename
(
const
char
* s);
95
96
DWORD
LastModified
()
const
{
return
last_modified
; }
97
98
static
Bitmap
*
Default
();
99
100
static
Bitmap
*
GetBitmapByID
(HANDLE bmp_id);
101
static
Bitmap
*
CheckCache
(
const
char
*
filename
);
102
static
void
AddToCache
(
Bitmap
* bmp);
103
static
void
CacheUpdate
();
104
static
void
ClearCache
();
105
static
DWORD
CacheMemoryFootprint
();
106
107
protected
:
108
int
type
;
109
int
width
;
110
int
height
;
111
int
mapsize
;
112
113
bool
ownpix
;
114
bool
alpha_loaded
;
115
bool
texture
;
116
117
ColorIndex
*
pix
;
118
Color
*
hipix
;
119
DWORD
last_modified
;
120
char
filename
[64];
121
};
122
123
#endif Bitmap_h
124
nGenEx
Bitmap.h
Generated on Tue Jun 5 2012 20:46:19 for Starshatter_Open by
1.8.1