-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchannel.c
73 lines (55 loc) · 2.01 KB
/
channel.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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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);
}
int main(int argc,char **argv) {
MagickBooleanType status;
MagickWand *magick_wand;
MagickWand *hsl_wand;
MagickWandGenesis();
magick_wand = NewMagickWand();
status = MagickReadImage(magick_wand, "./Biter_500.jpg");
if (status == MagickFalse) {
ThrowWandException(magick_wand);
}
hsl_wand = CloneMagickWand(magick_wand);
if (hsl_wand == NULL) {
printf("Failed to CloneMagickWand");
ThrowWandException(magick_wand);
}
status = MagickSeparateImageChannel(magick_wand, RedChannel);
status = MagickWriteImages(magick_wand, "channel1.rgb_before_%d.jpg", MagickTrue);
if (status == MagickFalse) {
ThrowWandException(magick_wand);
}
//status = MagickSetImageColorspace(hsl_wand, HSLColorspace);
status = MagickTransformImageColorspace(hsl_wand, HSLColorspace);
if (status == MagickFalse) {
printf("Failed to MagickSetImageColorspace");
ThrowWandException(magick_wand);
}
status = MagickSeparateImageChannel(hsl_wand, BlueChannel);
if (status == MagickFalse) {
printf("Failed to MagickSeparateImageChannel");
ThrowWandException(magick_wand);
}
status = MagickWriteImages(magick_wand, "channel1.rgb__after_%d.jpg", MagickTrue);
if (status == MagickFalse) {
ThrowWandException(magick_wand);
}
status = MagickWriteImages(hsl_wand, "channel1.hsl_%d.jpg", MagickTrue);
if (status == MagickFalse) {
ThrowWandException(magick_wand);
}
magick_wand = DestroyMagickWand(magick_wand);
MagickWandTerminus();
return(0);
}