imgITools.idl 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2. *
  3. * This Source Code Form is subject to the terms of the Mozilla Public
  4. * License, v. 2.0. If a copy of the MPL was not distributed with this
  5. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  6. #include "nsISupports.idl"
  7. interface nsIInputStream;
  8. interface imgIContainer;
  9. interface imgILoader;
  10. interface imgICache;
  11. interface nsIDOMDocument;
  12. interface imgIScriptedNotificationObserver;
  13. interface imgINotificationObserver;
  14. [scriptable, builtinclass, uuid(4c2383a4-931c-484d-8c4a-973590f66e3f)]
  15. interface imgITools : nsISupports
  16. {
  17. /**
  18. * decodeImage
  19. * Caller provides an input stream and mimetype. We read from the stream
  20. * and decompress it (according to the specified mime type) and return
  21. * the resulting imgIContainer.
  22. *
  23. * @param aStream
  24. * An input stream for an encoded image file.
  25. * @param aMimeType
  26. * Type of image in the stream.
  27. */
  28. imgIContainer decodeImage(in nsIInputStream aStream,
  29. in ACString aMimeType);
  30. /**
  31. * decodeImageData
  32. * Caller provides an input stream and mimetype. We read from the stream
  33. * and decompress it (according to the specified mime type) and return
  34. * the resulting imgIContainer.
  35. *
  36. * This method is deprecated and will be removed at some time in the future;
  37. * new code should use |decodeImage|.
  38. *
  39. * @param aStream
  40. * An input stream for an encoded image file.
  41. * @param aMimeType
  42. * Type of image in the stream.
  43. * @param aContainer
  44. * An imgIContainer holding the decoded image will be returned via
  45. * this parameter. It is an error to provide any initial value but
  46. * |null|.
  47. */
  48. [deprecated] void decodeImageData(in nsIInputStream aStream,
  49. in ACString aMimeType,
  50. inout imgIContainer aContainer);
  51. /**
  52. * encodeImage
  53. * Caller provides an image container, and the mime type it should be
  54. * encoded to. We return an input stream for the encoded image data.
  55. *
  56. * @param aContainer
  57. * An image container.
  58. * @param aMimeType
  59. * Type of encoded image desired (eg "image/png").
  60. * @param outputOptions
  61. * Encoder-specific output options.
  62. */
  63. nsIInputStream encodeImage(in imgIContainer aContainer,
  64. in ACString aMimeType,
  65. [optional] in AString outputOptions);
  66. /**
  67. * encodeScaledImage
  68. * Caller provides an image container, and the mime type it should be
  69. * encoded to. We return an input stream for the encoded image data.
  70. * The encoded image is scaled to the specified dimensions.
  71. *
  72. * @param aContainer
  73. * An image container.
  74. * @param aMimeType
  75. * Type of encoded image desired (eg "image/png").
  76. * @param aWidth, aHeight
  77. * The size (in pixels) desired for the resulting image. Specify 0 to
  78. * use the given image's width or height. Values must be >= 0.
  79. * @param outputOptions
  80. * Encoder-specific output options.
  81. */
  82. nsIInputStream encodeScaledImage(in imgIContainer aContainer,
  83. in ACString aMimeType,
  84. in long aWidth,
  85. in long aHeight,
  86. [optional] in AString outputOptions);
  87. /**
  88. * getImgLoaderForDocument
  89. * Retrieve an image loader that reflects the privacy status of the given
  90. * document.
  91. *
  92. * @param doc
  93. * A document. Must not be null.
  94. */
  95. imgILoader getImgLoaderForDocument(in nsIDOMDocument doc);
  96. /**
  97. * getImgLoaderForDocument
  98. * Retrieve an image cache that reflects the privacy status of the given
  99. * document.
  100. *
  101. * @param doc
  102. * A document. Null is allowed, but must _only_ be passed
  103. * when there is no way to obtain a relevant document for
  104. * the current context in which a cache is desired.
  105. */
  106. imgICache getImgCacheForDocument(in nsIDOMDocument doc);
  107. /**
  108. * encodeCroppedImage
  109. * Caller provides an image container, and the mime type it should be
  110. * encoded to. We return an input stream for the encoded image data.
  111. * The encoded image is cropped to the specified dimensions.
  112. *
  113. * The given offset and size must not exceed the image bounds.
  114. *
  115. * @param aContainer
  116. * An image container.
  117. * @param aMimeType
  118. * Type of encoded image desired (eg "image/png").
  119. * @param aOffsetX, aOffsetY
  120. * The crop offset (in pixels). Values must be >= 0.
  121. * @param aWidth, aHeight
  122. * The size (in pixels) desired for the resulting image. Specify 0 to
  123. * use the given image's width or height. Values must be >= 0.
  124. * @param outputOptions
  125. * Encoder-specific output options.
  126. */
  127. nsIInputStream encodeCroppedImage(in imgIContainer aContainer,
  128. in ACString aMimeType,
  129. in long aOffsetX,
  130. in long aOffsetY,
  131. in long aWidth,
  132. in long aHeight,
  133. [optional] in AString outputOptions);
  134. /**
  135. * Create a wrapper around a scripted notification observer (ordinarily
  136. * imgINotificationObserver cannot be implemented from scripts).
  137. *
  138. * @param aObserver The scripted observer to wrap
  139. */
  140. imgINotificationObserver
  141. createScriptedObserver(in imgIScriptedNotificationObserver aObserver);
  142. };