blob: 7fd288ef1b5842868bd32b0a74fa89623b4ce2ea (
plain)
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
|
/**
* The image
*
* Copyright: Mike Wey 2011
* License: To be determined
* Authors: Mike Wey
*/
module dmagick.Image;
import dmagick.Exception;
import dmagick.Options;
import dmagick.Utils;
import dmagick.c.constitute;
import dmagick.c.exception;
import dmagick.c.image;
class Image
{
alias dmagick.c.image.Image MagickCoreImage;
alias RefCounted!( DestroyImage, MagickCoreImage ) ImageRef;
ImageRef imageRef;
Options options;
this()
{
options = new Options();
imageRef = ImageRef(AcquireImage(options.imageInfo));
}
this(MagickCoreImage* image)
{
options = new Options();
imageRef = ImageRef(image);
}
this(string filename)
{
options = new Options();
read(filename);
}
this(Geometry size, Color color)
{
options = new Options();
options.size = size;
//Use read to create a cnavas with the spacified color.
read( "canvas:"~ color.toString() );
}
void read(string filename)
{
options.filename = filename;
ExceptionInfo* exception = AcquireExceptionInfo();
MagickCoreImage* image = ReadImage(options.imageInfo, exception);
DMagickException.throwException(exception);
imageRef = ImageRef(image);
DestroyExceptionInfo(exception);
}
}
|