Mozilla2:Image Encoding: Difference between revisions

mNo edit summary
 
(7 intermediate revisions by 3 users not shown)
Line 4: Line 4:
Something like:
Something like:


  interface imgIEncoder : nsISupports
  interface imgIEncoder : nsIInputStream
  {
  {
   void encode(in imgIContainer input, in nsIOutputStream output);
   /* input image data
    * result width
  /* Output width/height */
    * result height
  attribute unsigned long width;
    */
  attribute unsigned long height;
   void init(in imgIContainer input,
            in unsigned long width, in unsigned long height);
  /* type of scaling */
   const unsigned long SCALE_BAD = 0;
  const unsigned long SCALE_NORMAL = 1;
  const unsigned long SCALE_GOOD = 2;
  attribute unsigned long scaling;
  };
  };


=== encode() method ===
=== Scaling ===
Should we put width/height on the encode method?
Do we want to support different types of scaling?  I'd prefer to just do nice Bicubic resampling. [http://members.bellatlantic.net/~vze2vrva/design.html] [http://astronomy.swin.edu.au/~pbourke/colour/bicubic/]
 
=== 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.
 


=== Scaling ===
This expresses the idea that the encoder is something you read from.
Do we want to support different types of scaling?  I'm thinking we may not and may just want a solid good scaling algorithm that all encoders can use.


== 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