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 ***

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