bitblt_test.c

Tue, 01 Jan 2002 06:11:43 +0000

author
eric
date
Tue, 01 Jan 2002 06:11:43 +0000
changeset 30
35fad7ec7732
parent 11
30d18cf8bb67
child 43
b80cb5a4282a
permissions
-rw-r--r--

add support for PDF file attributes: author, creator, title, etc.

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