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