Mozilla2:Image Encoding: Difference between revisions

No edit summary
 
(One intermediate revision by one other user not shown)
Line 4: Line 4:
Something like:
Something like:


  interface imgIEncoder : nsISupports
  interface imgIEncoder : nsIInputStream
  {
  {
   /* input image data
   /* input image data
Line 10: Line 10:
     * result height
     * result height
     */
     */
   nsIInputStream encode(in imgIContainer input, in unsigned long width, in unsigned long height);
   void init(in imgIContainer input,
            in unsigned long width, in unsigned long height);
  };
  };
=== encode() method ===
Should we put width/height on the encode method?


=== Scaling ===
=== Scaling ===
Line 21: Line 19:
=== Brendan's comments ===
=== Brendan's comments ===
A reader should get the bytes requested, if not greater than length of encoded image, and it's up to the encoder to buffer more if it encodes more bytes, reading from the buffer on next read.
A reader should get the bytes requested, if not greater than length of encoded image, and it's up to the encoder to buffer more if it encodes more bytes, reading from the buffer on next read.
This expresses the idea that the encoder is something you read from.


== Use ==
== Use ==
You would create one by doing:
You would create one by doing:
  createInstance("@mozilla.org/image/encoder;2?type=image/png");
  createInstance("@mozilla.org/image/encoder;2?type=image/png");
569

edits