1 /* $Id: gfx2d.h,v 5.0 2001/04/07 20:00:58 dik Exp $ 2 * 3 * XPilot, a multiplayer gravity war game. Copyright (C) 1991-2001 by 4 * 5 * Bj�rn Stabell <bjoern@xpilot.org> 6 * Ken Ronny Schouten <ken@xpilot.org> 7 * Bert Gijsbers <bert@xpilot.org> 8 * Dick Balaska <dick@xpilot.org> 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2 of the License, or 13 * (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 */ 24 #ifndef GFX2D_H 25 #define GFX2D_H 26 27 typedef unsigned int RGB_COLOR; 28 29 #define RGB24(r, g, b) ((((b)&255) << 16) | (((g)&255) << 8) | ((r)&255)) 30 31 #define RED_VALUE(col) ((col) &255) 32 #define GREEN_VALUE(col) (((col) >> 8) &255) 33 #define BLUE_VALUE(col) (((col) >>16) &255) 34 35 /* 36 Purpose: bounding box for one image or a set of images. 37 The xmin and ymin elements give the lowest coordinate which 38 has a non-black color value. The xmax and ymax elements 39 give the highest coordinate which has a non-black color. 40 The number of pixels covered by one box is given by: 41 (xmax + 1 - xmin, ymax + 1 - ymin). 42 */ 43 typedef struct { 44 int xmin, ymin; 45 int xmax, ymax; 46 } bbox_t; 47 48 49 /* 50 Purpose: A device/os independent structure to do keep 24bit images in. 51 an instance of xp_picture_t can contain more than 1 image, 52 This feature is useful for structural identical bitmaps (example: items), 53 and rotated images. When dealing with rotated images, the first image 54 in the xp_picture_t structure is used as texture for the transformation of the 55 others. 56 */ 57 58 typedef struct { 59 int width, height; 60 int images; 61 RGB_COLOR **data; 62 63 bbox_t *bbox; 64 } xp_picture_t; 65 66 int Picture_init(xp_picture_t *picture, int height, int width, int images); 67 int Picture_load( xp_picture_t *picture, const char *path); 68 void Picture_rotate(xp_picture_t *picture); 69 70 void Picture_set_pixel(xp_picture_t *picture, int image, int x, int y, 71 RGB_COLOR color); 72 RGB_COLOR Picture_get_rotated_pixel(const xp_picture_t *picture, 73 int x, int y, int image); 74 RGB_COLOR Picture_get_pixel(const xp_picture_t *picture, int image, 75 int x, int y); 76 RGB_COLOR Picture_get_pixel_area(const xp_picture_t *picture, int image, 77 double x1, double y1, double dx, double dy); 78 void Picture_get_bounding_box(xp_picture_t *picture); 79 80 #endif 81