IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ticket #236: psFitsWriteImageBug.c

File psFitsWriteImageBug.c, 960 bytes (added by Paul Price, 21 years ago)

psFitsWriteImageBug.c

Line 
1#include <stdio.h>
2#include "pslib.h"
3
4#define NAME "test.fits"
5#define SIZE 128
6
7int main(int argc, char *argv[])
8{
9 // Make two images
10 psImage *image1 = psImageAlloc(SIZE, SIZE, PS_TYPE_F32);
11 psImage *image2 = psImageAlloc(SIZE, SIZE, PS_TYPE_F32);
12 for (int i = 0; i < SIZE; i++) {
13 for (int j = 0; j < SIZE; j++) {
14 image1->data.F32[i][j] = +1.0;
15 image2->data.F32[i][j] = -1.0;
16 }
17 }
18
19 // Write out the first one
20 psFits *fitsFile1 = psFitsAlloc(NAME);
21 if (!psFitsWriteImage(fitsFile1, NULL, image1, 0, NULL)) {
22 psErrorStackPrint(stderr, "Unable to write image: %s\n", NAME);
23 }
24 psFree(fitsFile1);
25
26 // Write out the second one
27 psFits *fitsFile2 = psFitsAlloc(NAME); // We "accidentally" on purpose give it the same name
28 if (!psFitsWriteImage(fitsFile2, NULL, image2, 0, NULL)) {
29 psErrorStackPrint(stderr, "Unable to write image: %s\n", NAME);
30 }
31 psFree(fitsFile2);
32
33 printf("Done.\n");
34}