/dmagick/c/layer.d

http://github.com/MikeWey/DMagick · D · 255 lines · 47 code · 26 blank · 182 comment · 0 complexity · 40b01600b731ef7e34870729000778e2 MD5 · raw file

  1. module dmagick.c.layer;
  2. import dmagick.c.composite;
  3. import dmagick.c.exception;
  4. import dmagick.c.image;
  5. alias ptrdiff_t ssize_t;
  6. extern(C)
  7. {
  8. /**
  9. * The dispose method used for GIF animations.
  10. *
  11. * See_Also: $(LINK2 http://www.imagemagick.org/Usage/anim_basics/#dispose,
  12. * Frame Disposal Methods) in the Examples of ImageMagick Usage.
  13. */
  14. enum DisposeType
  15. {
  16. /** */
  17. UnrecognizedDispose,
  18. /**
  19. * No disposal specified.
  20. */
  21. UndefinedDispose = 0,
  22. /**
  23. * Do not dispose between frames.
  24. */
  25. NoneDispose = 1,
  26. /**
  27. * Overwrite the image area with the background color.
  28. */
  29. BackgroundDispose = 2,
  30. /**
  31. * Overwrite the image area with what was there prior
  32. * to rendering the image.
  33. */
  34. PreviousDispose = 3
  35. }
  36. /**
  37. * Determines image operation to apply to ordered sequence of images.
  38. */
  39. enum ImageLayerMethod
  40. {
  41. /** */
  42. UndefinedLayer,
  43. /**
  44. * Apply the GIF disposal methods set in the current image sequence
  45. * to form a fully defined animation sequence without, as it should
  46. * be displayed. Effectively converting a GIF animation into
  47. * a 'film strip' like animation.
  48. */
  49. CoalesceLayer,
  50. /**
  51. * Crop the second and later frames to the smallest rectangle that
  52. * contains all the differences between the two images. No GIF
  53. * disposal methods are taken into account.
  54. *
  55. * This does not preserve a animation's normal working, especially
  56. * when a animation used GIF disposal methods
  57. * such as 'Previous' or 'Background'.
  58. */
  59. CompareAnyLayer,
  60. /**
  61. * As CompareAnyLayer but crop to the bounds of any opaque pixels
  62. * which become transparent in the second frame. That is the
  63. * smallest image needed to mask or erase pixels for the next frame.
  64. */
  65. CompareClearLayer,
  66. /**
  67. * As CompareAnyLayer but crop to pixels that add extra color to
  68. * the next image, as a result of overlaying color pixels. That is
  69. * the smallest single overlaid image to add or change colors.
  70. *
  71. * This can, be used with the -compose alpha composition method
  72. * 'change-mask', to reduce the image to just the pixels that need
  73. * to be overlaid.
  74. */
  75. CompareOverlayLayer,
  76. /**
  77. * This is like CoalesceLayer but shows the look of the animation
  78. * after the GIF disposal method has been applied, before the next
  79. * sub-frame image is overlaid. That is the 'dispose' image that
  80. * results from the application of the GIF disposal method. This
  81. * allows you to check what is going wrong with a particular
  82. * animation you may be developing.
  83. */
  84. DisposeLayer,
  85. /**
  86. * Optimize a coalesced animation into GIF animation using a number
  87. * of general techniques. This is currently a short cut to apply
  88. * both the OptimizeImageLayer and OptimizeTransLayer methods
  89. * but will expand to include other methods.
  90. */
  91. OptimizeLayer,
  92. /**
  93. * Optimize a coalesced animation into GIF animation by reducing
  94. * the number of pixels per frame as much as possible by attempting
  95. * to pick the best GIF disposal method to use, while ensuring the
  96. * result will continue to animate properly.
  97. *
  98. * There is no guarantee that the best optimization will be found.
  99. * But then no reasonably fast GIF optimization algorithm can do
  100. * this. However this does seem to do better than most other GIF
  101. * frame optimizers seen.
  102. */
  103. OptimizeImageLayer,
  104. /**
  105. * As OptimizeImageLayer but attempt to improve the overall
  106. * optimization by adding extra frames to the animation, without
  107. * changing the final look or timing of the animation. The frames
  108. * are added to attempt to separate the clearing of pixels from the
  109. * overlaying of new additional pixels from one animation frame to
  110. * the next. If this does not improve the optimization (for the next
  111. * frame only), it will fall back to the results of the previous
  112. * normal OptimizeImageLayer technique.
  113. *
  114. * There is the possibility that the change in the disposal style
  115. * will result in a worsening in the optimization of later frames,
  116. * though this is unlikely. In other words there no guarantee that
  117. * it is better than the normal 'optimize-frame' technique.
  118. */
  119. OptimizePlusLayer,
  120. /**
  121. * Given a GIF animation, replace any pixel in the sub-frame overlay
  122. * images with transparency, if it does not change the resulting
  123. * animation by more than the current fuzz factor.
  124. *
  125. * This should allow a existing frame optimized GIF animation to
  126. * compress into a smaller file size due to larger areas of one
  127. * (transparent) color rather than a pattern of multiple colors
  128. * repeating the current disposed image of the last frame.
  129. */
  130. OptimizeTransLayer,
  131. /**
  132. * Remove (and merge time delays) of duplicate consecutive images,
  133. * so as to simplify layer overlays of coalesced animations. Usually
  134. * this is a result of using a constant time delay across the whole
  135. * animation, or after a larger animation was split into smaller
  136. * sub-animations. The duplicate frames could also have been used as
  137. * part of some frame optimization methods.
  138. */
  139. RemoveDupsLayer,
  140. /**
  141. * Remove any image with a zero time delay, unless ALL the images
  142. * have a zero time delay (and is not a proper timed animation, a
  143. * warning is then issued). In a GIF animation, such images are
  144. * usually frames which provide partial intermediary updates between
  145. * the frames that are actually displayed to users. These frames are
  146. * usually added for improved frame optimization in GIF animations.
  147. */
  148. RemoveZeroLayer,
  149. /**
  150. * Alpha Composition of two image lists, separated by a "null:"
  151. * image, with the destination image list first, and the source
  152. * images last. An image from each list are composited together
  153. * until one list is finished. The separator image and source image
  154. * lists are removed.
  155. *
  156. * The geometry offset is adjusted according to gravity in
  157. * accordance of the virtual canvas size of the first image in each
  158. * list. Unlike a normal composite operation, the canvas offset is
  159. * also added to the final composite positioning of each image.
  160. *
  161. * If one of the image lists only contains one image, that image is
  162. * applied to all the images in the other image list, regardless of
  163. * which list it is. In this case it is the image meta-data of the
  164. * list which preserved.
  165. */
  166. CompositeLayer,
  167. /**
  168. * As FlattenLayer but merging all the given image layers into a
  169. * new layer image just large enough to hold all the image without
  170. * clipping or extra space. The new image's virtual offset will
  171. * prevere the position of the new layer, even if this offset is
  172. * negative. the virtual canvas size of the first image is preserved.
  173. *
  174. * Caution is advised when handling image layers with negative
  175. * offsets as few image file formats handle them correctly.
  176. */
  177. MergeLayer,
  178. /**
  179. * Create a canvas the size of the first images virtual canvas using
  180. * the current background color, and compose each image in turn onto
  181. * that canvas. Images falling outside that canvas will be clipped.
  182. * Final image will have a zero virtual canvas offset.
  183. *
  184. * This is usually used as one of the final 'image layering'
  185. * operations overlaying all the prepared image layers into a
  186. * final image.
  187. *
  188. * For a single image this method can also be used to fillout a
  189. * virtual canvas with real pixels, or to underlay a opaque color
  190. * to remove transparency from an image.
  191. */
  192. FlattenLayer,
  193. /**
  194. * As FlattenLayer but expanding the initial canvas size of the
  195. * first image so as to hold all the image layers. However as a
  196. * virtual canvas is 'locked' to the origin, by definition, image
  197. * layers with a negative offsets will still be clipped by the top
  198. * and left edges.
  199. *
  200. * This method is commonly used to layout individual image using
  201. * various offset but without knowing the final canvas size. The
  202. * resulting image will, like FlattenLayer not have any virtual
  203. * offset, so can be saved to any image file format. This method
  204. * corresponds to mosaic, above.
  205. */
  206. MosaicLayer,
  207. /**
  208. * Find the minimal bounds of all the images in the current image
  209. * sequence, then adjust the offsets so all images are contained
  210. * on a minimal positive canvas. None of the image data is modified,
  211. * only the virtual canvas size and offset. Then all the images will
  212. * have the same canvas size, and all will have a positive offset,
  213. * at least one image will touch every edge of that canvas with
  214. * actual pixel data, though that data may be transparent.
  215. */
  216. TrimBoundsLayer
  217. }
  218. Image* CoalesceImages(const(Image)*, ExceptionInfo*);
  219. Image* DisposeImages(const(Image)*, ExceptionInfo*);
  220. Image* CompareImageLayers(const(Image)*, const ImageLayerMethod, ExceptionInfo*);
  221. Image* DeconstructImages(const(Image)*, ExceptionInfo*);
  222. Image* MergeImageLayers(Image*, const ImageLayerMethod, ExceptionInfo*);
  223. Image* OptimizeImageLayers(const(Image)*, ExceptionInfo*);
  224. Image* OptimizePlusImageLayers(const(Image)*, ExceptionInfo*);
  225. void CompositeLayers(Image*, const CompositeOperator, Image*, const ssize_t, const ssize_t, ExceptionInfo*);
  226. void OptimizeImageTransparency(const(Image)*, ExceptionInfo*);
  227. void RemoveDuplicateLayers(Image**, ExceptionInfo*);
  228. void RemoveZeroDelayLayers(Image**, ExceptionInfo*);
  229. }