1
0
mirror of synced 2026-02-26 17:04:14 +00:00

use signed integers for coordinates.

This commit is contained in:
Eric Smith
2002-01-02 10:17:48 +00:00
parent 1d371905a7
commit 8996dcd2b2
3 changed files with 14 additions and 8 deletions

View File

@@ -12,20 +12,23 @@ static inline u8 pixel_mask (x)
#endif
}
static inline u32 rect_width (Rect r)
static inline s32 rect_width (Rect r)
{
return (r.lower_right.x - r.upper_left.x);
}
static inline u32 rect_height (Rect r)
static inline s32 rect_height (Rect r)
{
return (r.lower_right.y - r.upper_left.y);
}
Bitmap *create_bitmap (u32 width, u32 height)
Bitmap *create_bitmap (s32 width, s32 height)
{
Bitmap *bitmap;
if ((width <= 0) || (height <= 0))
return (NULL);
bitmap = calloc (1, sizeof (Bitmap));
if (! bitmap)
return (NULL);

View File

@@ -1,7 +1,7 @@
typedef struct Point
{
int x;
int y;
s32 x;
s32 y;
} Point;
typedef struct Rect
@@ -13,8 +13,8 @@ typedef struct Rect
typedef struct Bitmap
{
u8 *bits;
u32 width;
u32 height;
s32 width;
s32 height;
u32 rowbytes;
} Bitmap;
@@ -35,7 +35,7 @@ typedef struct Bitmap
#define ROT_270 (TRANSPOSE + FLIP_V)
Bitmap *create_bitmap (u32 width, u32 height);
Bitmap *create_bitmap (s32 width, s32 height);
void free_bitmap (Bitmap *bitmap);
boolean get_pixel (Bitmap *bitmap, Point coord);
void set_pixel (Bitmap *bitmap, Point coord, boolean value);

3
type.h
View File

@@ -1,4 +1,7 @@
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef int s32;
typedef int boolean;