use signed integers for coordinates.

Wed, 02 Jan 2002 10:17:48 +0000

author
eric
date
Wed, 02 Jan 2002 10:17:48 +0000
changeset 35
41804cc569ab
parent 34
8d7bd2fa5db6
child 36
a338db73c6f4

use signed integers for coordinates.

bitblt.c file | annotate | diff | revisions
bitblt.h file | annotate | diff | revisions
type.h file | annotate | diff | revisions
     1.1 --- a/bitblt.c	Wed Jan 02 10:17:24 2002 +0000
     1.2 +++ b/bitblt.c	Wed Jan 02 10:17:48 2002 +0000
     1.3 @@ -12,20 +12,23 @@
     1.4  #endif
     1.5  }
     1.6  
     1.7 -static inline u32 rect_width (Rect r)
     1.8 +static inline s32 rect_width (Rect r)
     1.9  {
    1.10    return (r.lower_right.x - r.upper_left.x);
    1.11  }
    1.12  
    1.13 -static inline u32 rect_height (Rect r)
    1.14 +static inline s32 rect_height (Rect r)
    1.15  {
    1.16    return (r.lower_right.y - r.upper_left.y);
    1.17  }
    1.18  
    1.19 -Bitmap *create_bitmap (u32 width, u32 height)
    1.20 +Bitmap *create_bitmap (s32 width, s32 height)
    1.21  {
    1.22    Bitmap *bitmap;
    1.23  
    1.24 +  if ((width <= 0) || (height <= 0))
    1.25 +    return (NULL);
    1.26 +
    1.27    bitmap = calloc (1, sizeof (Bitmap));
    1.28    if (! bitmap)
    1.29      return (NULL);
     2.1 --- a/bitblt.h	Wed Jan 02 10:17:24 2002 +0000
     2.2 +++ b/bitblt.h	Wed Jan 02 10:17:48 2002 +0000
     2.3 @@ -1,7 +1,7 @@
     2.4  typedef struct Point
     2.5  {
     2.6 -  int x;
     2.7 -  int y;
     2.8 +  s32 x;
     2.9 +  s32 y;
    2.10  } Point;
    2.11  
    2.12  typedef struct Rect
    2.13 @@ -13,8 +13,8 @@
    2.14  typedef struct Bitmap
    2.15  {
    2.16    u8 *bits;
    2.17 -  u32 width;
    2.18 -  u32 height;
    2.19 +  s32 width;
    2.20 +  s32 height;
    2.21    u32 rowbytes;
    2.22  } Bitmap;
    2.23  
    2.24 @@ -35,7 +35,7 @@
    2.25  #define ROT_270   (TRANSPOSE + FLIP_V)
    2.26  
    2.27  
    2.28 -Bitmap *create_bitmap (u32 width, u32 height);
    2.29 +Bitmap *create_bitmap (s32 width, s32 height);
    2.30  void free_bitmap (Bitmap *bitmap);
    2.31  boolean get_pixel (Bitmap *bitmap, Point coord);
    2.32  void set_pixel (Bitmap *bitmap, Point coord, boolean value);
     3.1 --- a/type.h	Wed Jan 02 10:17:24 2002 +0000
     3.2 +++ b/type.h	Wed Jan 02 10:17:48 2002 +0000
     3.3 @@ -1,4 +1,7 @@
     3.4  typedef unsigned char  u8;
     3.5  typedef unsigned short u16;
     3.6  typedef unsigned int   u32;
     3.7 +
     3.8 +typedef int            s32;
     3.9 +
    3.10  typedef int            boolean;