Mozilla2:Image Encoding: Difference between revisions
Line 6: | Line 6: | ||
interface imgIEncoder : nsISupports | interface imgIEncoder : nsISupports | ||
{ | { | ||
void encode(in imgIContainer input, in nsIOutputStream output | /* input image data | ||
* output stream | |||
* result width | |||
* result height | |||
*/ | |||
void encode(in imgIContainer input, in nsIOutputStream output, | |||
in unsigned long width, in unsigned long height); | |||
/* type of scaling */ | /* type of scaling */ | ||
Line 25: | Line 27: | ||
=== Scaling === | === Scaling === | ||
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. | 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. | ||
== Brendan's comments == | == Brendan's comments == |
Revision as of 02:24, 8 March 2005
Interface
We need to add a new interface. When you read from the stream should we encode just that much? Thoughts?
Something like:
interface imgIEncoder : nsISupports { /* input image data * output stream * result width * result height */ void encode(in imgIContainer input, in nsIOutputStream output, 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
Should we put width/height on the encode method?
Scaling
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.
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.
Pure functions are best, so make height and width parameters, please. Sure, you may store them internally (or something derived from them), but that doesn't mean that one-shot callers of encode should have to set two attributes first!
/be
Use
You would create one by doing:
createInstance("@mozilla.org/image/encoder;2?type=image/png");