bitblt_test.c

Thu, 27 Dec 2001 11:04:43 +0000

author
eric
date
Thu, 27 Dec 2001 11:04:43 +0000
changeset 2
8ca2aaf0513f
child 3
317de52d8a63
permissions
-rw-r--r--

Initial revision

     1 #include <stdio.h>
     3 #include "bitblt.h"
     6 #define WIDTH 20
     7 #define HEIGHT 9
     9 char test_data [HEIGHT][WIDTH] =
    10 {
    11   ".....XXXXXXXXXX.....",
    12   ".....XX.......X.....",
    13   "XXXXXX.X......XXXXXX",
    14   ".....X..X.....X.....",
    15   ".....X...X....X.....",
    16   ".....X....X...X.....",
    17   ".....X.....X..X.....",
    18   ".....XXXXXXXXXX.....",
    19   ".....XXXXXXXXXX....."
    20 };
    22 Bitmap *setup (void)
    23 {
    24   Bitmap *b;
    25   Point p;
    27   b = create_bitmap (WIDTH, HEIGHT);
    28   if (! b)
    29     return (NULL);
    31   for (p.y = 0; p.y < HEIGHT; p.y++)
    32     for (p.x = 0; p.x < WIDTH; p.x++)
    33       set_pixel (b, p, test_data [p.y][p.x] == 'X');
    35   return (b);
    36 }
    38 void print_bitmap (FILE *o, Bitmap *b)
    39 {
    40   Point p;
    41   printf ("rowbytes: %d\n", b->rowbytes);
    42   for (p.y = 0; p.y < b->height; p.y++)
    43     {
    44       for (p.x = 0; p.x < b->width; p.x++)
    45 	fputc (".X" [get_pixel (b, p)], o);
    46       fprintf (o, "\n");
    47     }
    48 }
    51 int main (int argc, char *argv[])
    52 {
    53   Bitmap *b;
    54   Bitmap *b2;
    55   Rect r;
    56   Point p;
    58   b = setup ();
    59   if (! b)
    60     {
    61       fprintf (stderr, "setup failed\n");
    62       exit (2);
    63     }
    65   print_bitmap (stdout, b);
    67   printf ("\n");
    69 #if 0
    70   b2 = create_bitmap (b->height, b->width);
    71   if (! b2)
    72     {
    73       fprintf (stderr, "create_bitmap failed\n");
    74       exit (2);
    75     }
    76 #endif
    78   r.upper_left.x = r.upper_left.y = 0;
    79   r.lower_right.x = b->width;
    80   r.lower_right.y = b->height;
    81   p.x = p.y = 0;
    83   b2 = bitblt (b, r,
    84 	       NULL, p,
    85 	       0, 0, 
    86 	       1,  /* transpose */
    87 	       TF_SRC);
    88   if (! b2)
    89     {
    90       fprintf (stderr, "bitblt failed\n");
    91       exit (2);
    92     }
    94   print_bitmap (stdout, b2);
    96   exit (0);
    97 }