bitblt_test.c

Tue, 22 Jan 2002 09:42:42 +0000

author
eric
date
Tue, 22 Jan 2002 09:42:42 +0000
changeset 43
b80cb5a4282a
parent 11
30d18cf8bb67
child 47
bfc6aaa089b0
permissions
-rw-r--r--

*** empty log message ***

     1 #include <stdio.h>
     2 #include <stdlib.h>
     4 #include "type.h"
     5 #include "bitblt.h"
     8 #define WIDTH 20
     9 #define HEIGHT 9
    11 char test_data [HEIGHT][WIDTH] =
    12 {
    13   ".....XXXXXXXXXX.....",
    14   ".....XX.......X.....",
    15   "XXXXXX.X......XXXXXX",
    16   ".....X..X.....X.....",
    17   ".....X...X....X.....",
    18   ".....X....X...X.....",
    19   ".....X.....X..X.....",
    20   ".....XXXXXXXXXX.....",
    21   ".....X.X.X.X.X......"
    22 };
    24 Bitmap *setup (void)
    25 {
    26   Bitmap *b;
    27   Point p;
    28   Rect r = {{ 0, 0 }, { WIDTH, HEIGHT }};
    30   b = create_bitmap (& r);
    31   if (! b)
    32     return (NULL);
    34   for (p.y = 0; p.y < HEIGHT; p.y++)
    35     for (p.x = 0; p.x < WIDTH; p.x++)
    36       set_pixel (b, p, test_data [p.y][p.x] == 'X');
    38   return (b);
    39 }
    41 void print_bitmap (FILE *o, Bitmap *b)
    42 {
    43   Point p;
    44   printf ("row_words: %d\n", b->row_words);
    45   for (p.y = b->rect.min.y; p.y < b->rect.max.y; p.y++)
    46     {
    47       for (p.x = b->rect.min.x; p.x < b->rect.max.x; p.x++)
    48 	fputc (".X" [get_pixel (b, p)], o);
    49       fprintf (o, "\n");
    50     }
    51 }
    54 int main (int argc, char *argv[])
    55 {
    56   Bitmap *b;
    57   Bitmap *b2;
    58   Rect r;
    59   Point p;
    61   b = setup ();
    62   if (! b)
    63     {
    64       fprintf (stderr, "setup failed\n");
    65       exit (2);
    66     }
    68   print_bitmap (stdout, b);
    69   printf ("\n");
    71   flip_v (b);
    73   print_bitmap (stdout, b);
    74   printf ("\n");
    76   flip_h (b);
    78   print_bitmap (stdout, b);
    79   printf ("\n");
    81 #if 0
    82   r.upper_left.x = r.upper_left.y = 0;
    83   r.lower_right.x = b->width;
    84   r.lower_right.y = b->height;
    85   p.x = p.y = 0;
    87   b2 = bitblt (b, r,
    88 	       NULL, p,
    89 	       ROT_90,
    90 	       TF_SRC);
    91   if (! b2)
    92     {
    93       fprintf (stderr, "bitblt failed\n");
    94       exit (2);
    95     }
    97   print_bitmap (stdout, b2);
    98 #endif
   100   exit (0);
   101 }