-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwand.c
84 lines (68 loc) · 1.69 KB
/
wand.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
#include <stdio.h>
#include <stdlib.h>
#include <wand/MagickWand.h>
DrawingWand* initDrawingWand()
{
#define ThrowWandException(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); \
}
/* DEFINE PARAMETERS required for output:
x size
y wize
TODO: default values
TODO: arg parameters
*/
MagickBooleanType
status;
MagickWand
*magick_wand;
PixelWand
*bgcolor;
DrawingWand
*drawing_wand;
/*
if (argc != 3)
{
(void) fprintf(stdout,"Usage: %s image thumbnail\n",argv[0]);
exit(0);
}
*/
/*
Initialize an image.
*/
MagickWandGenesis();
magick_wand=NewMagickWand();
bgcolor=NewPixelWand();
PixelSetColor(bgcolor, "#0000ff");
MagickSetBackgroundColor(magick_wand, bgcolor);
MagickSetSize(magick_wand, 600, 600);
MagickNewImage(magick_wand, 600, 600, bgcolor);
drawing_wand = NewDrawingWand();
return drawing_wand;
/* THIS IS WHERE THE MAGIK HAPPENS */
DrawCircle(drawing_wand, 100, 100, 120, 120);
/* THIS IS WHERE THE MAGIK HAPPENS */
MagickDrawImage(magick_wand, drawing_wand);
//MagickConstituteImage(wand,600,600,"RGB",CharPixel,pixels);
if (status == MagickFalse)
ThrowWandException(magick_wand);
/*
Write the image then destroy it.
*/
status=MagickWriteImages(magick_wand,"output.png",MagickTrue);
if (status == MagickFalse)
ThrowWandException(magick_wand);
magick_wand=DestroyMagickWand(magick_wand);
MagickWandTerminus();
return(0);
}