-
Notifications
You must be signed in to change notification settings - Fork 0
/
displaceComposite2.c
77 lines (53 loc) · 2.1 KB
/
displaceComposite2.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
#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);
}
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) {
MagickBooleanType status;
PixelWand *pixelWand;
MagickWand *magick_wand_a;
MagickWand *magick_wand_b;
//MagickWand *magick_wand_c;
MagickWandGenesis();
magick_wand_a = NewMagickWand();
status = MagickReadImage(magick_wand_a, "./displaceCompositeA.png");
if (status == MagickFalse) {
ThrowWandException(magick_wand_a);
}
magick_wand_b = NewMagickWand();
status = MagickReadImage(magick_wand_b, "./displaceMask.png");
if (status == MagickFalse) {
ThrowWandException(magick_wand_b);
}
MagickSetImageVirtualPixelMethod(magick_wand_a, TransparentVirtualPixelMethod);
pixelWand = makePixelWand("none");
status = MagickSetImageBackgroundColor(magick_wand_a, pixelWand);
MagickSetOption(magick_wand_a, "compose:args", "300x53.033");
status = MagickCompositeImage(magick_wand_a, magick_wand_b, DisplaceCompositeOp, 0, 0);
if (status == MagickFalse) {
printf("Failed to composite image b");
exit(-1);
}
status = MagickWriteImages(magick_wand_a, "displaceOutputMerged.png", MagickTrue);
MagickWandTerminus();
printf("Finished - please compare displaceOutputMerged.png with the result of:\n\n");
printf("convert displaceCompositeA.png displaceMask.png -virtual-pixel transparent -channel rgba -alpha on -background transparent -define compose:args=300x53.033 -compose displace -composite displaceMerged.png");
return(0);
}