bitblt_test.c

Thu, 27 Dec 2001 11:17:28 +0000

author
eric
date
Thu, 27 Dec 2001 11:17:28 +0000
changeset 3
317de52d8a63
parent 2
8ca2aaf0513f
child 11
30d18cf8bb67
permissions
-rw-r--r--

*** empty log message ***

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