diff --git a/bitblt.c b/bitblt.c index 2701e32..c84b3e1 100644 --- a/bitblt.c +++ b/bitblt.c @@ -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); diff --git a/bitblt.h b/bitblt.h index a8f4c06..65d32aa 100644 --- a/bitblt.h +++ b/bitblt.h @@ -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); diff --git a/type.h b/type.h index d3e7f8d..edb8e8f 100644 --- a/type.h +++ b/type.h @@ -1,4 +1,7 @@ typedef unsigned char u8; typedef unsigned short u16; typedef unsigned int u32; + +typedef int s32; + typedef int boolean;