1 module dmagick.c.image;
2 
3 import core.stdc.stdio;
4 import core.stdc.time;
5 
6 import dmagick.c.cacheView;
7 import dmagick.c.color;
8 import dmagick.c.colorspace;
9 import dmagick.c.composite;
10 import dmagick.c.compress;
11 import dmagick.c.compress;
12 import dmagick.c.effect;
13 import dmagick.c.exception;
14 import dmagick.c.geometry;
15 import dmagick.c.layer;
16 import dmagick.c.magickType;
17 import dmagick.c.magickVersion;
18 import dmagick.c.monitor;
19 import dmagick.c.pixel;
20 import dmagick.c.profile;
21 import dmagick.c.quantum;
22 import dmagick.c.resample;
23 import dmagick.c.semaphore;
24 import dmagick.c.stream;
25 import dmagick.c.timer;
26 
27 alias ptrdiff_t ssize_t;
28 
29 extern(C)
30 {
31 	/**
32 	 * Used to set a flag on an image indicating whether or not to use
33 	 * existing alpha channel data, to create an alpha channel, or to
34 	 * perform other operations on the alpha channel.
35 	 */
36 	enum AlphaChannelType
37 	{
38 		/** */
39 		UndefinedAlphaChannel,
40 
41 		/**
42 		 * Enable the image's transparency channel. Note normally
43 		 * SetAlphaChannel should be used instead of this, unless you
44 		 * specifically need to preserve existing (but specifically turned
45 		 * Off) transparency channel.
46 		 */
47 		ActivateAlphaChannel,
48 
49 		/**
50 		 * Set any fully-transparent pixel to the background color, while
51 		 * leaving it fully-transparent. This can make some image file
52 		 * formats, such as PNG, smaller as the RGB values of transparent
53 		 * pixels are more uniform, and thus can compress better.
54 		 */
55 		BackgroundAlphaChannel,
56 
57 		/**
58 		 * Turns On the alpha/matte channel, then copies the gray-scale
59 		 * intensity of the image, into the alpha channel, converting a
60 		 * gray-scale mask into a transparent shaped mask ready to be
61 		 * colored appropriately. The color channels are not modified.
62 		 */
63 		CopyAlphaChannel,
64 
65 		/**
66 		 * Disables the image's transparency channel. Does not delete or
67 		 * change the existing data, just turns off the use of that data.
68 		 */
69 		DeactivateAlphaChannel,
70 
71 		/**
72 		 * Copies the alpha channel values into all the color channels and
73 		 * turns 'Off' the the image's transparency, so as to generate a
74 		 * gray-scale mask of the image's shape. The alpha channel data is
75 		 * left intact just deactivated. This is the inverse of
76 		 * CopyAlphaChannel.
77 		 */
78 		ExtractAlphaChannel,
79 
80 		/**
81 		 * Enables the alpha/matte channel and forces it to be fully opaque.
82 		 */
83 		OpaqueAlphaChannel,
84 
85 		/** */
86 		ResetAlphaChannel,
87 
88 		/**
89 		 * Activates the alpha/matte channel. If it was previously turned
90 		 * off then it also resets the channel to opaque. If the image
91 		 * already had the alpha channel turned on, it will have no effect.
92 		 */
93 		SetAlphaChannel,
94 
95 		/**
96 		 * As per CopyAlphaChannel but also colors the resulting shape mask
97 		 * with the current background color. That is the RGB color channels
98 		 * is replaced, with appropriate alpha shape.
99 		 */
100 		ShapeAlphaChannel,
101 
102 		/**
103 		 * Activates the alpha/matte channel and forces it to be fully
104 		 * transparent. This effectively creates a fully transparent image
105 		 * the same size as the original and with all its original RGB data
106 		 * still intact, but fully transparent.
107 		 */
108 		TransparentAlphaChannel,
109 
110 		/**
111 		 * Flatten image pixels over the background pixels.
112 		 * 
113 		 * Since: ImageMagick 6.7.6.
114 		 */
115 		FlattenAlphaChannel,
116 
117 		/** ditto */
118 		RemoveAlphaChannel,
119 
120 		/** */
121 		AssociateAlphaChannel,
122 
123 		/** */
124 		DisassociateAlphaChannel
125 	}
126 
127 	/**
128 	 * Indicate the type classification of the image.
129 	 */
130 	enum ImageType
131 	{
132 		UndefinedType,       /// No type has been specified.
133 		BilevelType,         /// Monochrome image.
134 		GrayscaleType,       /// Grayscale image.
135 		GrayscaleMatteType,  /// Grayscale image with opacity.
136 		PaletteType,         /// Indexed color (palette) image.
137 		PaletteMatteType,    /// Indexed color (palette) image with opacity.
138 		TrueColorType,       /// Truecolor image.
139 		TrueColorMatteType,  /// Truecolor image with opacity.
140 		ColorSeparationType, /// Cyan/Yellow/Magenta/Black (CYMK) image.
141 		ColorSeparationMatteType, /// Cyan/Yellow/Magenta/Black (CYMK) image with opacity.
142 		OptimizeType,        ///
143 		PaletteBilevelMatteType   ///
144 	}
145 
146 	/**
147 	 * Specify the ordering of the red, green, and blue pixel information in
148 	 * the image. Interlacing is usually used to make image information
149 	 * available to the user faster by taking advantage of the space vs
150 	 * time tradeoff. For example, interlacing allows images on the Web to
151 	 * be recognizable sooner and satellite images to accumulate/render with
152 	 * image resolution increasing over time. Use LineInterlace or
153 	 * PlaneInterlace to create an interlaced GIF or progressive JPEG image.
154 	 */
155 	enum InterlaceType
156 	{
157 		/**
158 		 * No interlace type has been specified.
159 		 */
160 		UndefinedInterlace,
161 
162 		/**
163 		 * Don't interlace image (RGBRGBRGBRGBRGBRGB...).
164 		 */
165 		NoInterlace,
166 
167 		/**
168 		 * Use scanline interlacing (RRR...GGG...BBB...RRR...GGG...BBB...).
169 		 */
170 		LineInterlace,
171 
172 		/**
173 		 * Use plane interlacing (RRRRRR...GGGGGG...BBBBBB...).
174 		 */
175 		PlaneInterlace,
176 
177 		/**
178 		 * Similar to plane interlacing except that the different planes are
179 		 * saved to individual files (e.g. image.R, image.G, and image.B)
180 		 */
181 		PartitionInterlace,
182 
183 		/** */
184 		GIFInterlace,
185 
186 		/** */
187 		JPEGInterlace,
188 
189 		/** */
190 		PNGInterlace
191 	}
192 
193 	/**
194 	 * Specify the orientation of the image pixels.
195 	 */
196 	enum OrientationType
197 	{
198 		/**
199 		 * See_Also: $(LINK http://jpegclub.org/exif_orientation.html )
200 		 */
201 		UndefinedOrientation,
202 		TopLeftOrientation,      /// ditto
203 		TopRightOrientation,     /// ditto
204 		BottomRightOrientation,  /// ditto
205 		BottomLeftOrientation,   /// ditto
206 		LeftTopOrientation,      /// ditto
207 		RightTopOrientation,     /// ditto
208 		RightBottomOrientation,  /// ditto
209 		LeftBottomOrientation    /// ditto
210 	}
211 
212 	/**
213 	 * By default, ImageMagick defines resolutions in pixels per inch.
214 	 * ResolutionType provides a means to adjust this.
215 	 */
216 	enum ResolutionType
217 	{
218 		/**
219 		 * No resolution has been specified.
220 		 */
221 		UndefinedResolution,
222 
223 		/**
224 		 * Density specifications are specified in units
225 		 * of pixels per inch (English units).
226 		 */
227 		PixelsPerInchResolution,
228 
229 		/**
230 		 * Density specifications are specified in units
231 		 * of pixels per centimeter (metric units).
232 		 */
233 		PixelsPerCentimeterResolution
234 	}
235 
236 	/** */
237 	struct PrimaryInfo
238 	{
239 		double
240 			x, /// X ordinate.
241 			y, /// Y ordinate.
242 			z; /// Z ordinate. This attribute is always ignored.
243 	}
244 
245 	struct SegmentInfo
246 	{
247 		double
248 			x1,
249 			y1,
250 			x2,
251 			y2;
252 	}
253 
254 	enum TransmitType
255 	{
256 		UndefinedTransmitType,
257 		FileTransmitType,
258 		BlobTransmitType,
259 		StreamTransmitType,
260 		ImageTransmitType
261 	}
262 
263 	/**
264 	 * A Chromaticity object represents chromaticity values.
265 	 */
266 	struct ChromaticityInfo
267 	{
268 		PrimaryInfo
269 			red_primary,   /// Red primary point (e.g. red_primary.x=0.64, red_primary.y=0.33)
270 			green_primary, /// Green primary point (e.g. green_primary.x=0.3, green_primary.y=0.6)
271 			blue_primary,  /// Blue primary point (e.g. blue_primary.x=0.15, blue_primary.y=0.06)
272 			white_point;   /// White point (e.g. white_point.x=0.3127, white_point.y=0.329)
273 	}
274 
275 	struct Image
276 	{
277 		ClassType
278 			storage_class;
279 
280 		ColorspaceType
281 			colorspace;      /* colorspace of image data */
282 
283 		CompressionType
284 			compression;     /* compression of image when read/write */
285 
286 		size_t
287 			quality;         /* compression quality setting, meaning varies */
288 
289 		OrientationType
290 			orientation;     /* photo orientation of image */
291 
292 		MagickBooleanType
293 			taint,           /* has image been modified since reading */
294 			matte;           /* is transparency channel defined and active */
295 
296 		size_t
297 			columns,         /* physical size of image */
298 			rows,
299 			depth,           /* depth of image on read/write */
300 			colors;          /* size of color table on read */
301 
302 		PixelPacket*
303 			colormap;
304 
305 		PixelPacket
306 			background_color, /* current background color attribute */
307 			border_color,     /* current bordercolor attribute */
308 			matte_color;      /* current mattecolor attribute */
309 
310 		double
311 			gamma;
312 
313 		ChromaticityInfo
314 			chromaticity;
315 
316 		RenderingIntent
317 			rendering_intent;
318 
319 		void*
320 			profiles;
321 
322 		ResolutionType
323 			units;           /* resolution/density  ppi or ppc */
324 
325 		char*
326 			montage,
327 			directory,
328 			geometry;
329 
330 		ssize_t
331 			offset;
332 
333 		double
334 			x_resolution,    /* image resolution/density */
335 			y_resolution;
336 
337 		RectangleInfo
338 			page,            /* virtual canvas size and offset of image */
339 			extract_info,
340 			tile_info;       /* deprecated */
341 
342 		double
343 			bias,
344 			blur,            /* deprecated */
345 			fuzz;            /* current color fuzz attribute */
346 
347 		FilterTypes
348 			filter;          /* resize/distort filter to apply */
349 
350 		InterlaceType
351 			interlace;
352 
353 		EndianType
354 			endian;          /* raw data integer ordering on read/write */
355 
356 		GravityType
357 			gravity;         /* Gravity attribute for positioning in image */
358 
359 		CompositeOperator
360 			compose;         /* alpha composition method for layered images */
361 
362 		DisposeType
363 			dispose;         /* GIF animation disposal method */
364 
365 		Image*
366 			clip_mask;
367 
368 		size_t
369 			scene,           /* index of image in multi-image file */
370 			delay;           /* Animation delay time */
371 
372 		ssize_t
373 			ticks_per_second;  /* units for delay time, default 100 for GIF */
374 
375 		size_t
376 			iterations,
377 			total_colors;
378 
379 		ssize_t
380 			start_loop;
381 
382 		ErrorInfo
383 			error;
384 
385 		TimerInfo
386 			timer;
387 
388 		MagickProgressMonitor
389 			progress_monitor;
390 
391 		void*
392 			client_data,
393 			cache,
394 			attributes;      /* deprecated */
395 
396 		Ascii85Info*
397 			ascii85;
398 
399 		BlobInfo*
400 			blob;
401 
402 		char[MaxTextExtent]
403 			filename,        /* images input filename */
404 			magick_filename, /* ditto with coders, and read_mods */
405 			magick;          /* Coder used to decode image */
406 
407 		size_t
408 			magick_columns,
409 			magick_rows;
410 
411 		ExceptionInfo
412 			exception;       /* Error handling report */
413 
414 		MagickBooleanType
415 			ddebug;          /* debug output attribute */
416 
417 		ssize_t
418 			reference_count;
419 
420 		SemaphoreInfo*
421 			semaphore;
422 
423 		ProfileInfo
424 			color_profile,
425 			iptc_profile;
426 
427 		ProfileInfo*
428 			generic_profile;
429 
430 		size_t
431 			generic_profiles;
432 
433 		size_t
434 			signature;
435 
436 		Image*
437 			previous,        /* Image list links */
438 			list,            /* Undo/Redo image processing list (for display) */
439 			next;            /* Image list links */
440 
441 		InterpolatePixelMethod
442 			interpolate;     /* Interpolation of color for between pixel lookups */
443 
444 		MagickBooleanType
445 			black_point_compensation;
446 
447 		PixelPacket
448 			transparent_color; /* color for 'transparent' color index in GIF */
449 
450 		Image*
451 			mask;
452 
453 		RectangleInfo
454 			tile_offset;
455 
456 		void*
457 			properties,      /* per image properities */
458 			artifacts;       /* per image sequence image artifacts */
459 
460 		ImageType
461 			type;
462 
463 		MagickBooleanType
464 			dither;          /* dithering method during color reduction */
465 
466 		MagickSizeType
467 			extent;
468 
469 		static if ( MagickLibVersion >= 0x662 )
470 		{
471 			MagickBooleanType
472 				ping;
473 		}
474 
475 		static if ( MagickLibVersion >= 0x670 )
476 		{
477 			size_t
478 				channels;
479 		}
480 
481 		static if ( MagickLibVersion >= 0x683 )
482 		{
483 			time_t
484 				timestamp;
485 		}
486 
487 		static if ( MagickLibVersion >= 0x684 )
488 		{
489 			PixelIntensityMethod
490 				intensity;      /* method to generate an intensity value from a pixel */
491 		}
492 
493 		static if ( MagickLibVersion >= 0x689 )
494 		{
495 			/** Total animation duration sum(delay*iterations) */
496 			size_t duration;
497 		}
498 	}
499 
500 	struct ImageInfo
501 	{
502 		CompressionType
503 			compression;
504 
505 		OrientationType
506 			orientation;
507 
508 		MagickBooleanType
509 			temporary,
510 			adjoin,
511 			affirm,
512 			antialias;
513 
514 		char*
515 			size,
516 			extract,
517 			page,
518 			scenes;
519 
520 		size_t
521 			scene,
522 			number_scenes,
523 			depth;
524 
525 		InterlaceType
526 			interlace;
527 
528 		EndianType
529 			endian;
530 
531 		ResolutionType
532 			units;
533 
534 		size_t
535 			quality;
536 
537 		char*
538 			sampling_factor,
539 			server_name,
540 			font,
541 			texture,
542 			density;
543 
544 		double
545 			pointsize,
546 			fuzz;
547 
548 		PixelPacket
549 			background_color,
550 			border_color,
551 			matte_color;
552 
553 		MagickBooleanType
554 			dither,
555 			monochrome;
556 
557 		size_t
558 			colors;
559 
560 		ColorspaceType
561 			colorspace;
562 
563 		ImageType
564 			type;
565 
566 		PreviewType
567 			preview_type;
568 
569 		ssize_t
570 			group;
571 
572 		MagickBooleanType
573 			ping,
574 			verbose;
575 
576 		char*
577 			view,
578 			authenticate;
579 
580 		ChannelType
581 			channel;
582 
583 		Image*
584 			attributes;
585 
586 		void*
587 			options;
588 
589 		MagickProgressMonitor
590 			progress_monitor;
591 
592 		void*
593 			client_data,
594 			cache;
595 
596 		StreamHandler
597 			stream;
598 
599 		FILE*
600 			file;
601 
602 		void*
603 			blob;
604 
605 		size_t
606 			length;
607 
608 		char[MaxTextExtent]
609 			magick,
610 			unique,
611 			zero,
612 			filename;
613 
614 		MagickBooleanType
615 			ddebug;
616 
617 		char*
618 			tile;
619 
620 		size_t
621 			subimage,
622 			subrange;
623 
624 		PixelPacket
625 			pen;
626 
627 		size_t
628 			signature;
629 
630 		VirtualPixelMethod
631 			virtual_pixel_method;
632 
633 		PixelPacket
634 			transparent_color;
635 
636 		void*
637 			profile;
638 
639 		MagickBooleanType
640 			synchronize;
641 	}
642 
643 	ExceptionType CatchImageException(Image*);
644 
645 	FILE* GetImageInfoFile(const(ImageInfo)*);
646 
647 	Image* AcquireImage(const(ImageInfo)*);
648 	Image* AppendImages(const(Image)*, const MagickBooleanType, ExceptionInfo*);
649 	Image* CloneImage(const(Image)*, const size_t, const size_t, const MagickBooleanType, ExceptionInfo*);
650 	Image* DestroyImage(Image*);
651 	Image* GetImageClipMask(const(Image)*, ExceptionInfo*);
652 	Image* GetImageMask(const(Image)*, ExceptionInfo*);
653 	Image* NewMagickImage(const(ImageInfo)*, const size_t, const size_t, const(MagickPixelPacket)*);
654 	Image* ReferenceImage(Image*);
655 
656 	static if ( MagickLibVersion >= 0x668 )
657 	{
658 		Image* SmushImages(const(Image)*, const MagickBooleanType, const ssize_t, ExceptionInfo*);
659 	}
660 
661 	ImageInfo* AcquireImageInfo();
662 	ImageInfo* CloneImageInfo(const(ImageInfo)*);
663 	ImageInfo* DestroyImageInfo(ImageInfo*);
664 
665 	static if (MagickLibVersion < 0x662)
666 	{
667 		MagickBooleanType AcquireImageColormap(Image*, const size_t);
668 	}
669 
670 	MagickBooleanType ClipImage(Image*);
671 	MagickBooleanType ClipImagePath(Image*, const(char)*, const MagickBooleanType);
672 	MagickBooleanType IsTaintImage(const(Image)*);
673 	MagickBooleanType IsMagickConflict(const(char)*);
674 	MagickBooleanType IsHighDynamicRangeImage(const(Image)*, ExceptionInfo*);
675 	MagickBooleanType IsImageObject(const(Image)*);
676 	MagickBooleanType ListMagickInfo(FILE*, ExceptionInfo*);
677 	MagickBooleanType ModifyImage(Image**, ExceptionInfo*);
678 	MagickBooleanType ResetImagePage(Image*, const(char)*);
679 	MagickBooleanType SetImageBackgroundColor(Image*);
680 	MagickBooleanType SetImageClipMask(Image*, const(Image)*);
681 
682 	static if (MagickLibVersion >= 0x662)
683 	{
684 		MagickBooleanType SetImageColor(Image*, const(MagickPixelPacket)*);
685 	}
686 
687 	MagickBooleanType SetImageColor(Image*, const(MagickPixelPacket)*);
688 	MagickBooleanType SetImageExtent(Image*, const size_t, const size_t);
689 	MagickBooleanType SetImageInfo(ImageInfo*, const uint, ExceptionInfo*);
690 	MagickBooleanType SetImageMask(Image*, const(Image)*);
691 	MagickBooleanType SetImageOpacity(Image*, const Quantum);
692 
693 	static if ( MagickLibVersion >= 0x670 )
694 	{
695 		MagickBooleanType SetImageChannels(Image*, const size_t);
696 	}
697 
698 	MagickBooleanType SetImageStorageClass(Image*, const ClassType);
699 	MagickBooleanType StripImage(Image*);
700 	MagickBooleanType SyncImage(Image*);
701 	MagickBooleanType SyncImageSettings(const(ImageInfo)*, Image*);
702 	MagickBooleanType SyncImagesSettings(ImageInfo*, Image*);
703 
704 	size_t InterpretImageFilename(const(ImageInfo)*, Image*, const(char)*, int, char*);
705 
706 	ssize_t GetImageReferenceCount(Image*);
707 
708 	static if ( MagickLibVersion >= 0x670 )
709 	{
710 		size_t GetImageChannels(Image*);
711 	}
712 
713 	VirtualPixelMethod GetImageVirtualPixelMethod(const(Image)*);
714 	VirtualPixelMethod SetImageVirtualPixelMethod(const(Image)*, const VirtualPixelMethod);
715 
716 	void AcquireNextImage(const(ImageInfo)*, Image*);
717 	void DestroyImagePixels(Image*);
718 	void DisassociateImageStream(Image*);
719 	void GetImageException(Image*, ExceptionInfo*);
720 	void GetImageInfo(ImageInfo*);
721 	void SetImageInfoBlob(ImageInfo*, const(void)*, const size_t);
722 	void SetImageInfoFile(ImageInfo*, FILE*);
723 }