imgIContainer is the interface that represents an image. It allows
access to frames as Thebes surfaces. It also allows drawing of images
onto Thebes contexts.
Internally, imgIContainer also manages animation of images.
Given a size at which this image will be displayed, and the drawing
parameters affecting how it will be drawn, returns the image size which
should be used to draw to produce the highest quality result. This is the
appropriate size, for example, to use as an input to the pixel snapping
algorithm.
For best results the size returned by this method should not be cached. It
can change over time due to changes in the internal state of the image.
aDest | The size of the destination rect into which this image will be drawn, in device pixels. |
aWhichFrame | Frame specifier of the FRAME_* variety. |
aFilter | The filter to be used if we're scaling the image. |
aFlags | Flags of the FLAG_* variety |
Direct C++ accessor for ‘type’ attribute, for convenience.
Get a surface for the given frame. This may be a platform-native,
optimized surface, so you cannot inspect its pixel data. If you
need that, use SourceSurface::GetDataSurface.
aWhichFrame | Frame specifier of the FRAME_* variety. |
aFlags | Flags of the FLAG_* variety |
Whether the given frame is opaque; that is, needs the background painted
behind it.
aWhichFrame | Frame specifier of the FRAME_* variety. |
Attempts to create an ImageContainer (and Image) containing the current
frame. Only valid for RASTER type images.
Draw the requested frame of this image onto the context specified.
Drawing an image involves scaling it to a certain size (which may be
implemented as a “smart” scale by substituting an HQ-scaled frame or
rendering at a high DPI), and then selecting a region of that image to
draw. That region is drawn onto the graphics context and in the process
transformed by the context matrix, which determines the final area that is
filled. The basic process looks like this:
+------------------+
| Image |
| |
| intrinsic width |
| X |
| intrinsic height |
+------------------+
/ \
/ \
/ (scale to aSize) \
/ \
+----------------------------+
| |
| Scaled Image |
| aSize.width X aSize.height |
| |
| +---------+ |
| | aRegion | |
| +---------+ |
+-------(---------(----------+
| |
/ \
| (transform |
/ by aContext \
| matrix) |
/ \
+---------------------+
| |
| Fill Rect |
| |
+---------------------+
The region may extend outside of the scaled image’s boundaries. It’s
actually a region in tiled image space, which is formed by tiling the
scaled image infinitely in every direction. Drawing with a region larger
than the scaled image thus causes the filled area to contain multiple tiled
copies of the image, which looks like this:
....................................................
: : : :
: Tile : Tile : Tile :
: +------------[aRegion]------------+ :
:........|.......:................:........|.......:
: | : : | :
: Ti|le : Scaled Image : Ti|le :
: | : : | :
:........|.......:................:........|.......:
: +---------------------------------+ :
: Ti|le : Tile : Ti|le :
: / : : \ :
:......(.........:................:..........).....:
| |
/ \
| (transform by aContext matrix) |
/ \
+---------------------------------------------+
| : : |
|.....:.................................:.....|
| : : |
| : Tiled Fill : |
| : : |
|.....:.................................:.....|
| : : |
+---------------------------------------------+
aContext | The Thebes context to draw the image to. |
aSize | The size to which the image should be scaled before drawing. This requirement may be satisfied using HQ scaled frames, selecting from different resolution layers, drawing at a higher DPI, or just performing additional scaling on the graphics context. Callers can use optimalImageSizeForDest() to determine the best choice for this parameter if they have no special size requirements. |
aRegion | The region in tiled image space which will be drawn onto the graphics context. aRegion is in the coordinate space of the image after it has been scaled to aSize - that is, the image is scaled first, and then aRegion is applied. When aFlags includes FLAG_CLAMP, the image will be extended to this area by clamping image sample coordinates. Otherwise, the image will be automatically tiled as necessary. aRegion can also optionally contain a second region which restricts the set of pixels we're allowed to sample from when drawing; this is only of use to callers which need to draw with pixel snapping. |
aWhichFrame | Frame specifier of the FRAME_* variety. |
aFilter | The filter to be used if we're scaling the image. |
aSVGContext | If specified, SVG-related rendering context, such as overridden attributes on the image document's root |