1 /** 2 * Describes an image 3 */ 4 module harud.image; 5 6 import harud.c; 7 import harud.haruobject; 8 import harud.types; 9 import std.conv; 10 11 /** 12 * Image class 13 */ 14 class Image : IHaruObject { 15 protected HPDF_Image _image; 16 17 this(HPDF_Image image) { 18 _image = image; 19 } 20 21 /** 22 * Gets the size of the image of an image object. 23 * 24 * Returns: 25 * When succeed, it returns a $(LINK2 harud/c/types/Point.html, Point) struct which includes the size of the image. 26 * Otherwise, it returns a $(LINK2 harud/c/types/Point.html, Point) struct whose value is (0, 0). 27 */ 28 Point getSize() { 29 return HPDF_Image_GetSize(this._image); 30 } 31 32 /** 33 * Gets the width of the image of an image object. 34 * 35 * Returns: 36 * When succeed, it returns the width of the image. Otherwise, it returns 0. 37 */ 38 uint getWidth() { 39 return HPDF_Image_GetWidth(this._image); 40 } 41 42 /** 43 * Gets the height of the image of an image object. 44 * 45 * Returns: 46 * when succeed, it returns the height of the image. Otherwise, it returns 0. 47 */ 48 uint getHeight() { 49 return HPDF_Image_GetHeight(this._image); 50 } 51 52 /** 53 * Gets the number of bits used to describe each color component. 54 */ 55 uint getBitsPerComponent() { 56 return HPDF_Image_GetBitsPerComponent(this._image); 57 } 58 59 /** 60 * Gets the name of the image's color space. 61 * 62 * Returns: 63 * when getColorSpace() succeed, it returns the following values. Otherwise, it returns null. 64 * $(UL 65 * $(LI DeviceGray) 66 * $(LI DeviceRGB) 67 * $(LI DeviceCMYK) 68 * $(LI Indexed) 69 * ) 70 */ 71 string getColorSpace() { 72 return to!string(HPDF_Image_GetColorSpace(this._image)); 73 } 74 75 /** 76 * Sets the transparent color of the image by the RGB range values. 77 * 78 * The color within the range is displayed as a transparent color. The Image must be RGB color space. 79 * 80 * Params: 81 * rmin = The lower limit of Red. It must be between 0 and 255. 82 * rmax = The upper limit of Red. It must be between 0 and 255. 83 * gmin = The lower limit of Green. It must be between 0 and 255. 84 * gmax = The upper limit of Green. It must be between 0 and 255. 85 * bmin = The lower limit of Blue. It must be between 0 and 255. 86 * bmax = The upper limit of Blue. It must be between 0 and 255. 87 */ 88 HPDF_STATUS setColorMask(uint rmin, uint rmax, uint gmin, uint gmax, uint bmin, uint bmax) 89 90 in { 91 assert(rmin < 256, "rmin should less than 256"); 92 assert(rmax < 256, "rmax should less than 256"); 93 assert(gmin < 256, "gmin should less than 256"); 94 assert(gmax < 256, "gmax should less than 256"); 95 assert(bmin < 256, "bmin should less than 256"); 96 assert(bmax < 256, "bmax should less than 256"); 97 } 98 do { 99 return HPDF_Image_SetColorMask(this._image, rmin, rmax, gmin, gmax, bmin, bmax); 100 } 101 102 void setMaskImage(Image maskImage) { 103 HPDF_Image_SetMaskImage(this._image, maskImage.getHandle()); 104 } 105 106 public HPDF_HANDLE getHandle() { 107 return _image; 108 } 109 }