1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
/*
# This file is part of the Astrometry.net suite.
# Licensed under a 3-clause BSD style license - see LICENSE
*/
#include <math.h>
#include <stdio.h>
#include <string.h>
#include "cutest.h"
#include "plotstuff.h"
#include "plotfill.h"
#include "plotxy.h"
#include "plotimage.h"
#include "log.h"
#include "cairoutils.h"
void test_plot_wcs1(CuTest* tc) {
plot_args_t myargs;
plot_args_t* pargs = &myargs;
int W, H;
plotxy_t* xy;
//plotimage_t* img;
log_init(LOG_VERB);
W = H = 5;
plotstuff_init(pargs);
plotstuff_set_size(pargs, W, H);
pargs->outformat = PLOTSTUFF_FORMAT_PNG;
pargs->outfn = "test-out1.png";
plotstuff_set_color(pargs, "black");
plotstuff_run_command(pargs, "fill");
plotstuff_output(pargs);
plotstuff_free(pargs);
// perfectly centered circle.
plotstuff_init(pargs);
plotstuff_set_size(pargs, W, H);
pargs->outformat = PLOTSTUFF_FORMAT_PNG;
pargs->outfn = "test-out2.png";
plotstuff_set_color(pargs, "black");
plotstuff_run_command(pargs, "fill");
xy = plotstuff_get_config(pargs, "xy");
plot_xy_vals(xy, 3, 3);
plotstuff_set_color(pargs, "white");
plotstuff_set_marker(pargs, "circle");
plotstuff_set_markersize(pargs, 1);
plotstuff_run_command(pargs, "xy");
plotstuff_output(pargs);
plotstuff_free(pargs);
// perfectly centered circle.
plotstuff_init(pargs);
plotstuff_set_size(pargs, W, H);
pargs->outformat = PLOTSTUFF_FORMAT_PNG;
pargs->outfn = "test-out3.png";
plotstuff_set_color(pargs, "black");
plotstuff_run_command(pargs, "fill");
xy = plotstuff_get_config(pargs, "xy");
plot_xy_vals(xy, 2, 2);
plot_xy_set_offsets(xy, 0, 0);
plotstuff_set_color(pargs, "white");
plotstuff_set_marker(pargs, "circle");
plotstuff_set_markersize(pargs, 1);
plotstuff_run_command(pargs, "xy");
plotstuff_output(pargs);
plotstuff_free(pargs);
{
unsigned char* img;
int ww, hh;
int i;
img = cairoutils_read_png("test-out2.png", &ww, &hh);
CuAssertPtrNotNull(tc, img);
CuAssertIntEquals(tc, W, ww);
CuAssertIntEquals(tc, H, hh);
printf("image:\n");
for (i=0; i<W*H; i++) {
printf("%02x ", (int)img[i*4]);
if (i%W == (W-1))
printf("\n");
}
printf("\n");
/*
00 00 00 00 00
00 80 e8 80 00
00 f3 44 f3 00
00 7c e8 7c 00
00 00 00 00 00
*/
}
}
|