25 #include <SDL/SDL_endian.h> 29 #if SDL_BYTEORDER == SDL_BIG_ENDIAN 30 #define R_MASK 0x00ff0000 31 #define G_MASK 0x0000ff00 32 #define B_MASK 0x000000ff 33 #define A_MASK 0xff000000 35 #define R_MASK 0x000000ff 36 #define G_MASK 0x0000ff00 37 #define B_MASK 0x00ff0000 38 #define A_MASK 0xff000000 54 if (screen::dbl_mode ()) {
62 vis = SDL_DisplayFormat (s);
63 SDL_SetColorKey (
vis, SDL_SRCCOLORKEY | SDL_RLEACCEL,
64 SDL_MapRGB (
vis->format, color.r, color.g, color.b));
125 rawdata =
new char[l * h * 3];
128 raw2display (rawdata, l, h);
130 delete[] (
char *) rawdata;
161 raw2display (rawdata, l, h);
177 file = SDL_RWFromFile (fname.c_str (),
"rb");
217 SDL_Surface *tmp2 = SDL_CreateRGBSurface (0, 1, 1, 24,
222 SDL_Surface * toconvert;
227 imt->double_size(*
this);
228 toconvert = imt->
vis;
235 SDL_Surface * temp = SDL_ConvertSurface (toconvert, tmp2->format, 0);
237 SDL_LockSurface (temp);
246 SDL_UnlockSurface (temp);
248 SDL_FreeSurface (temp);
249 SDL_FreeSurface (tmp2);
268 SDL_Surface *tmp2 = SDL_CreateRGBSurface (0, 1, 1, 24,
277 imt.half_size(*
this);
278 temp = SDL_ConvertSurface (imt.
vis, tmp2->format, 0);
282 temp = SDL_ConvertSurface (
vis, tmp2->format, 0);
287 SDL_FreeSurface (temp);
288 SDL_FreeSurface (tmp2);
298 file = SDL_RWFromFile (fname.c_str (),
"wb");
325 for (j = y; j < h + y; j++)
328 for (i = x; i < l + x; i++)
330 src.
get_pix (xcur >> 16, ycur >> 16, col);
347 for (posy = 0; posy < h; posy += src.
height ())
348 for (posx = 0; posx < l; posx += src.
length ())
349 src.
draw (x + posx, y + posy, &da,
this);
363 for (j = 0; j <
height (); j++)
364 for (i = 0; i <
length (); i++)
369 src.
get_pix (i, j, ir, ig, ib);
370 ir = (ir * cont) >> 8;
371 ig = (ig * cont) >> 8;
372 ib = (ib * cont) >> 8;
402 SDL_Surface *tmp2 = SDL_CreateRGBSurfaceFrom (rawdata,
length (),
407 vis = SDL_DisplayFormat (tmp2);
411 imt.double_size(*
this);
414 SDL_FreeSurface (tmp2);
s_int8 get_pnm(SDL_RWops *file)
Loads an image from an opened file, in PNM format, without alpha and mask values. ...
Class to write data from a Gzip compressed file.
void close()
Close the file that was opened.
void set_length(u_int16 l)
Sets the length of the drawable.
u_int16 length() const
Returns the length of the drawable.
bool is_masked() const
Returns whether a surface is masked or not.
Class to read data from a Gzip compressed file.
void resize(u_int16 l, u_int16 h)
Resize this image.
#define u_int16
16 bits long unsigned integer
s_int8 load(string fname)
Loads an image from a file name, in game internal format, with alpha and mask values.
void set_height(u_int16 h)
Sets the height of the drawable.
Class where drawables can actually be drawn to.
static void put(SDL_RWops *file, void *image, u_int16 length, u_int16 height)
Saves a PNM image into an opened file.
Image manipulation class.
#define u_int32
32 bits long unsigned integer
#define u_int8
8 bits long unsigned integer
void resize(u_int16 l, u_int16 h)
Resize this surface.
image()
Default constructor.
void tile(const surface &src)
Tiles a surface.
Declares the image class.
void clear()
Resets the image to it's initial state, that is totally empty.
s_int8 save(string fname) const
Saves an image into an file, in game format, with alpha and mask values.
s_int8 load_raw(string fname)
Loads an image from a file name, in game internal format, without alpha and mask values.
void unlock() const
Unlock the surface after you've worked on it's pixels with the get_pix () and put_pix () methods...
u_int8 alpha() const
Returns the alpha value of the surface.
void clear()
Resets the surface to it's initial state, that is totally empty.
void draw(s_int16 x, s_int16 y, const drawing_area *da_opt=NULL, surface *target=NULL) const
Draw the surface.
s_int8 put_pnm(SDL_RWops *file) const
Saves an image into an opened file, in PNM format, without alpha and mask values. ...
s_int8 save_pnm(string fname) const
Saves an image into an file, in PNM format, without alpha and mask values.
bool is_open()
Returns whether the file is opened or not.
s_int8 put(ogzstream &file) const
Saves an image into an opened file, in game format, with alpha and mask values.
Implements "drawing zones" for drawing operations.
image & operator=(const image &src)
Image copy (similar to copy ()).
void set_alpha(u_int8 a)
Sets the alpha value of the surface.
u_int16 height() const
Returns the height of the drawable.
SDL_Surface * vis
The actual surface.
void zoom(const surface &src)
Zooms a surface.
s_int8 get(igzstream &file)
Loads an image from an opened file, saved in game internal format, with alpha and mask values...
s_int8 put_raw(ogzstream &file) const
Saves an image into an opened file, in game format, without alpha and mask values.
Declares the pnm static class.
void brightness(const surface &src, u_int8 cont, bool proceed_mask=false)
Applies a "brightness" to a surface.
s_int8 load_pnm(string fname)
Loads an image from a file name, in PNM format, without alpha and mask values.
void get_pix(u_int16 x, u_int16 y, u_int32 &col) const
Gets a pixel from the surface.
bool changed
Must be set to true when you change the surface by something else than class surface operations...
s_int8 save_raw(string fname) const
Saves an image into an file, in game format, without alpha and mask values.
s_int8 get_raw(igzstream &file)
Loads an image from an opened file, saved in game internal format, without alpha and mask values...
static void * get(SDL_RWops *file, u_int16 *length, u_int16 *height)
Reads a PNM image from an opened file.
static u_int32 trans_col()
Returns the translucent color in screen's depth format.
#define s_int8
8 bits long signed integer
void set_mask(bool m)
Sets the mask parameter of the surface.
void get_block(void *to, u_int32 size)
Reads a block of bytes from the file.
void lock() const
Locks the surface.
void put_block(void *to, u_int32 size)
Writes a block of bytes to the file.
void put_pix(u_int16 x, u_int16 y, u_int32 col)
Puts a pixel of a given color.