/[crust]/crust/libs/GraphicsFoundation/testsuite/bitmap-test-render.c
ViewVC logotype

Diff of /crust/libs/GraphicsFoundation/testsuite/bitmap-test-render.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by jrydberg, Tue Aug 28 16:10:34 2001 UTC revision 1.4 by jrydberg, Mon Sep 17 12:37:01 2001 UTC
# Line 25  Line 25 
25  #include <errno.h>  #include <errno.h>
26  #include <error.h>  #include <error.h>
27  #include <math.h>  #include <math.h>
28    #include <assert.h>
29    
30  #define IMAGE_WIDTH  800  #define IMAGE_WIDTH  800
31  #define IMAGE_HEIGHT 250  #define IMAGE_HEIGHT 250
32  #define IMAGE_PITCH  (IMAGE_WIDTH * 4)  #define IMAGE_PITCH  (IMAGE_WIDTH * 4)
33    
34    unsigned int pattern_data [2*2] =
35      {
36        0xffffffff, 0x00000000,
37        0x00000000, 0xffffffff
38      };
39    
40  int  int
41  main (int argc, char *argv)  main (int argc, char *argv)
42  {  {
43    GFColorSpaceRef colorspace;    GFColorSpaceRef colorspace, pattern;
44      GFImageRef image, dst_img;
45    GFContextRef context;    GFContextRef context;
46    void *buffer;    void *buffer;
47    FILE *fp;    FILE *fp;
48    
49    buffer = malloc (IMAGE_PITCH * IMAGE_HEIGHT);    dst_img = GFImageCreate (IMAGE_WIDTH, IMAGE_HEIGHT, 4, 8,
50    if (! buffer)                             kGFImageAlphaSeparateLast);
     error (1, ENOMEM, "Could not allocate pixel buffer");  
   memset (buffer, 0x80, IMAGE_PITCH * IMAGE_HEIGHT);  
   
51    colorspace = GFColorSpaceCreateDeviceRGB ();    colorspace = GFColorSpaceCreateDeviceRGB ();
52        context = GFBitmapContextCreate (dst_img, colorspace);
   context = GFBitmapContextCreate (buffer, IMAGE_WIDTH, IMAGE_HEIGHT, 8,  
                                    IMAGE_PITCH, colorspace,  
                                    kCGImageAlphaSeparateLast);  
53    if (context)    if (context)
54      {      {
55        GFRect rect = GFRectMake (10, 10, IMAGE_WIDTH - 20, IMAGE_HEIGHT - 20);        GFRect rect = GFRectMake (10, 10, IMAGE_WIDTH - 20, IMAGE_HEIGHT - 20);
56    
57        GFContextSaveGState (context);        GFContextSaveGState (context);
   
58        GFContextSetRGBFillColor (context, 0.0, 0.0, 0.0, 0.8);        GFContextSetRGBFillColor (context, 0.0, 0.0, 0.0, 0.8);
59    
60        GFContextSelectFont (context, "Courier", "Bold", 40.0);        GFContextSelectFont (context, "Courier", "Bold", 40.0);
# Line 81  main (int argc, char *argv) Line 82  main (int argc, char *argv)
82        fp = fopen ("bitmap-test-render.rgba", "w");        fp = fopen ("bitmap-test-render.rgba", "w");
83        if (fp)        if (fp)
84          {          {
85            fwrite (buffer, IMAGE_PITCH, IMAGE_HEIGHT, fp);            fwrite (dst_img->pixels, IMAGE_PITCH, IMAGE_HEIGHT, fp);
86            fclose (fp);            fclose (fp);
87          }          }
88        else        else
89          error (1, 0, "Could not create output file");          error (1, 0, "Could not create output file");
90        free (buffer);        free (dst_img->pixels);
91          free (dst_img);
92      }      }
93    else    else
94      error (1, 0, "Could not create bitmap context");      error (1, 0, "Could not create bitmap context");

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26