bitblt_test.c

Thu, 20 Feb 2003 12:20:28 +0000

author
eric
date
Thu, 20 Feb 2003 12:20:28 +0000
changeset 60
ffb5b1e54eb2
parent 48
3d0be1c1c1b2
child 137
ce565d98baf3
permissions
-rw-r--r--

fix includes.

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