Partial reimplementation of image unpacking routines
[phoros.git] / imreadtest.c
blob5064911174ea7d5da3250210d14b73f67326446e
1 #include "imread.h"
3 int
4 main(int argc, char *argv[])
6 char *in_path, *out_path;
7 unsigned long width, height, channels, start, size, compression_mode, demosaic_fast;
8 FILE *fp;
9 int bayer_pattern[2] = {0x00ff00, 0x0000ff};
10 double color_raiser[3] = {1, 1, 1};
11 struct png_store mp;
12 int err;
14 setvbuf(stdout, NULL, _IONBF, 0);
15 if (argc >= 11) {
16 in_path = argv[1];
17 width = strtoul(argv[2], NULL, 10);
18 height = strtoul(argv[3], NULL, 10);
19 channels = strtoul(argv[4], NULL, 10);
20 start = strtoul(argv[5], NULL, 10);
21 size = strtoul(argv[6], NULL, 10);
22 compression_mode = strtoul(argv[7], NULL, 10);
23 demosaic_fast = strtoul(argv[8], NULL, 10);
24 sscanf(argv[9], "%lf, %lf, %lf", &color_raiser[0], &color_raiser[1], &color_raiser[2]);
25 out_path = argv[10];
26 err = png2mem(in_path, start, size, width, height, channels,
27 bayer_pattern, demosaic_fast, compression_mode,
28 &mp, false, false, color_raiser);
29 fp = fopen(out_path, "wb");
30 if (fp == NULL)
31 fprintf(stderr, "Could not open file %s for writing\n", "o0.png");
32 fwrite(mp.buffer, mp.size, sizeof(mp.buffer[0]), fp);
33 printf("status=%d\n", err);
34 printf("in_path=%s width=%ld height=%ld channels=%ld start=%ld size=%ld compression_mode=%ld demosaic_fast=%ld color_raiser=%.1lf,%.1lf,%.1lf out_path=%s\n",
35 in_path, width, height, channels, start, size, compression_mode, demosaic_fast,
36 color_raiser[0], color_raiser[1], color_raiser[2], out_path);
37 if(mp.buffer)
38 free(mp.buffer);
39 return 0;
41 if (argc == 2) {
42 printf("ping = %d\n", ping(strtoul(argv[1], NULL, 10)));
43 return 0;
45 printf("Usage: %s in_path width height channels start size compression_mode demosaic_fast color_raiser out_path", argv[0]);
46 return 1;
49 /* ./imreadtest mitsa005_CCD_Front_PULNIX_13.pictures 1700 1500 3 2264 1392908 2 1 1,1,1 m.png */
50 /* ./imreadtest phoros_20110405_002_CCDHECK_01_PULNIX_11.pictures 1920 1080 1 1 1363 1384533 2 1,1,1 p.png */
51 /* ./imreadtest 15294_IRIS3_20160519_000_CCD_RETRO_ZEB_1.pictures 1920 1080 4 1 1210 598189 3 1,1,1 j.png */