-
Notifications
You must be signed in to change notification settings - Fork 0
/
sparseTest.c
97 lines (80 loc) · 2.48 KB
/
sparseTest.c
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Use this one for IM7
#include <MagickWand/MagickWand.h>
// Use this one for IM6
//#include <wand/MagickWand.h>
void ThrowWandException(MagickWand *wand) {
char *description;
ExceptionType severity;
description = MagickGetException(wand, &severity);
(void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description);
description=(char *) MagickRelinquishMemory(description);
exit(-1);
}
PixelWand *makePixelWand(char *string) {
PixelWand *pixel_wand;
pixel_wand = NewPixelWand();
if (PixelSetColor (pixel_wand, string) == MagickFalse) {
printf("Failed to set color");
exit(-1);
}
return pixel_wand;
}
int main(int argc,char **argv) {
MagickWand *magick_wand;
char *filename;
PixelWand *stroke_color_wand;
MagickBooleanType status;
int num_elements;
#if MagickLibVersion < 0x700
long channel = RedChannel | GreenChannel | BlueChannel | AlphaChannel;
#else
ChannelType channel = RedChannel | GreenChannel | BlueChannel | AlphaChannel;
//ChannelType channel = RedChannel | GreenChannel | BlueChannel;
#endif
double double_array[] = {
150.000000, 50.000000,
1.000000, 0.000000, 0.000000, 1.0,
50.000000, 400.000000,
0.000000, 0.000000, 1.000000, 0.5,
350.000000, 300.000000,
0.000000, 1.000000, 0.000000, 1.0,
400.000000, 100.000000,
1.000000, 1.000000, 0.000000, 0.1,
};
num_elements = sizeof(double_array) / sizeof(double);
MagickWandGenesis();
stroke_color_wand = makePixelWand("rgba(255, 255, 255, 1)");
magick_wand = NewMagickWand();
MagickNewImage(magick_wand, 500, 500, stroke_color_wand);
#if MagickLibVersion >= 0x700
printf("I choose you IM 7 \n");
filename = "./sparseTest_7.png";
MagickSetImageChannelMask(magick_wand, channel);
status = MagickSparseColorImage(
magick_wand,
BilinearColorInterpolate,
num_elements,
double_array
);
#else
printf("I choose you IM 6 \n");
filename = "./sparseTest_6.png";
status = MagickSparseColorImage(
magick_wand,
channel,
BilinearColorInterpolate,
num_elements,
double_array
);
#endif
if (status == MagickFalse) {
ThrowWandException(magick_wand);
}
MagickWriteImages(magick_wand, filename, MagickTrue);
MagickWandTerminus();
printf("fin\n");
return (0);
}