com.aspose.html.rendering.image

Class ImageDevice

  • All Implemented Interfaces:
    IDevice, com.aspose.ms.System.IDisposable


    public class ImageDevice
    extends Device<ImageGraphicContext,ImageRenderingOptions>

    Represents rendering to raster formats: jpeg, png, bmp, gif, tiff.

    See Also:
    ImageGraphicContext
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void addRect(com.aspose.ms.System.Drawing.RectangleF rect)
      Appends a rectangle to the current path as a complete subpath.
      boolean beginElement(Element element, com.aspose.ms.System.Drawing.RectangleF rect)
      Begins rendering of the html element.
      void beginPage(com.aspose.ms.System.Drawing.SizeF size)
      Begins rendering of the new page.
      void clip(int mode)
      Modifies the current clipping path by intersecting it with the current path, using the FillMode rule to determine the region to fill.
      void closePath()
      Closes the current subpath by appending a straight line segment from the current point to the starting point of the subpath.
      void cubicBezierTo(com.aspose.ms.System.Drawing.PointF pt1, com.aspose.ms.System.Drawing.PointF pt2, com.aspose.ms.System.Drawing.PointF pt3)
      Appends a cubic Bézier curve to the current path.
      void drawImage(byte[] data, int type, com.aspose.ms.System.Drawing.RectangleF rect)
      Draws the specified image.
      void endDocument()
      Ends rendering of the document.
      void endElement(Element element)
      Ends rendering of the html element.
      void endPage()
      Ends rendering of the current page.
      void fill(int mode)
      Fills the entire region enclosed by the current path.
      void fillText(String text, com.aspose.ms.System.Drawing.PointF pt)
      Fills the specified text string at the specified location.
      Class<? extends GraphicContext> getGraphicContextClass()
      Pushes a copy of the entire graphics context onto the stack.
      com.aspose.ms.System.Drawing.Graphics getGraphics()
      Gets the instance of Graphics.
      com.aspose.ms.System.IO.Stream getInternalOutputStream() 
      int getInternalPageIndex() 
      void lineTo(com.aspose.ms.System.Drawing.PointF pt)
      Appends a straight line segment from the current point to the point (pt).
      void moveTo(com.aspose.ms.System.Drawing.PointF pt)
      Begins a new subpath by moving the current point to coordinates of the parameter pt, omitting any connecting line segment.
      void restoreGraphicContext()
      Restores the entire graphics context to its former value by popping it from the stack.
      void saveGraphicContext()
      Pushes a copy of the entire graphics context onto the stack.
      void stroke()
      Strokes a line along the current path.
      void strokeAndFill(int mode)
      Strokes and fill current path.
      void strokeText(String text, com.aspose.ms.System.Drawing.PointF pt)
      Strokes the specified text string at the specified location.
    • Constructor Detail

      • ImageDevice

        public ImageDevice(ImageRenderingOptions options,
                           ICreateStreamProvider streamProvider)

        Initializes a new instance of the ImageDevice class by rendering options and stream provider.

        Parameters:
        options - Rendering options.
        streamProvider - Object that implements the ICreateStreamProvider interface
      • ImageDevice

        public ImageDevice(ImageRenderingOptions options,
                           String file)

        Initializes a new instance of the ImageDevice class by rendering options and output file name.

        Parameters:
        options - Rendering options.
        file - The output file name.
      • ImageDevice

        public ImageDevice(ImageRenderingOptions options,
                           com.aspose.ms.System.IO.Stream stream)

        Initializes a new instance of the ImageDevice class by rendering options and output stream.

        Parameters:
        options - Rendering options.
        stream - The output stream.
    • Method Detail

      • beginElement

        public boolean beginElement(Element element,
                                    com.aspose.ms.System.Drawing.RectangleF rect)

        Begins rendering of the html element.

        Specified by:
        beginElement in interface IDevice
        Specified by:
        beginElement in class Device<ImageGraphicContext,ImageRenderingOptions>
        Parameters:
        element - The html element.
        rect - Bounding box of the node.
        Returns:
        Returns [true] if element should be processed.
      • closePath

        public void closePath()

        Closes the current subpath by appending a straight line segment from the current point to the starting point of the subpath. If the current subpath is already closed, "ClosePath" does nothing. This operator terminates the current subpath. Appending another segment to the current path begins a new subpath, even if the new segment begins at the endpoint reached by the "ClosePath" method.

        Specified by:
        closePath in interface IDevice
        Specified by:
        closePath in class Device<ImageGraphicContext,ImageRenderingOptions>
      • moveTo

        public void moveTo(com.aspose.ms.System.Drawing.PointF pt)

        Begins a new subpath by moving the current point to coordinates of the parameter pt, omitting any connecting line segment. If the previous path construction method in the current path was also "MoveTo", the new "MoveTo" overrides it; no vestige of the previous "MoveTo" operation remains in the path.

        Specified by:
        moveTo in interface IDevice
        Specified by:
        moveTo in class Device<ImageGraphicContext,ImageRenderingOptions>
        Parameters:
        pt - Point of where to move the path to.
      • lineTo

        public void lineTo(com.aspose.ms.System.Drawing.PointF pt)

        Appends a straight line segment from the current point to the point (pt). The new current point is pt.

        Specified by:
        lineTo in interface IDevice
        Specified by:
        lineTo in class Device<ImageGraphicContext,ImageRenderingOptions>
        Parameters:
        pt - Point of where to create the line to.
      • addRect

        public void addRect(com.aspose.ms.System.Drawing.RectangleF rect)

        Appends a rectangle to the current path as a complete subpath.

        Specified by:
        addRect in interface IDevice
        Specified by:
        addRect in class Device<ImageGraphicContext,ImageRenderingOptions>
        Parameters:
        rect - A rectangle to draw.
      • cubicBezierTo

        public void cubicBezierTo(com.aspose.ms.System.Drawing.PointF pt1,
                                  com.aspose.ms.System.Drawing.PointF pt2,
                                  com.aspose.ms.System.Drawing.PointF pt3)

        Appends a cubic Bézier curve to the current path. The curve extends from the current point to the point pt2, using pt1 and pt2 as the Bézier control points. The new current point is pt3.

        Specified by:
        cubicBezierTo in interface IDevice
        Specified by:
        cubicBezierTo in class Device<ImageGraphicContext,ImageRenderingOptions>
        Parameters:
        pt1 - Coordinates of first point
        pt2 - Coordinates of second point
        pt3 - Coordinates of third point
      • stroke

        public void stroke()

        Strokes a line along the current path. The stroked line follows each straight or curved segment in the path, centered on the segment with sides parallel to it. Each of the path’s subpaths is treated separately. This method terminates current path.

        Specified by:
        stroke in interface IDevice
        Specified by:
        stroke in class Device<ImageGraphicContext,ImageRenderingOptions>
      • fill

        public void fill(int mode)

        Fills the entire region enclosed by the current path. If the path consists of several disconnected subpaths, it fills the insides of all subpaths, considered together. This method terminates current path.

        Specified by:
        fill in interface IDevice
        Specified by:
        fill in class Device<ImageGraphicContext,ImageRenderingOptions>
        Parameters:
        mode - Filling mode specifies how the interior of a closed path is filled
      • clip

        public void clip(int mode)

        Modifies the current clipping path by intersecting it with the current path, using the FillMode rule to determine the region to fill. This method terminates current path.

        Specified by:
        clip in interface IDevice
        Specified by:
        clip in class Device<ImageGraphicContext,ImageRenderingOptions>
        Parameters:
        mode - Filling mode specifies how the interior of a closed path is clipped
      • strokeAndFill

        public void strokeAndFill(int mode)

        Strokes and fill current path. This method terminates current path.

        Specified by:
        strokeAndFill in interface IDevice
        Specified by:
        strokeAndFill in class Device<ImageGraphicContext,ImageRenderingOptions>
        Parameters:
        mode - Filling mode specifies how the interior of a closed path is filled.
      • fillText

        public void fillText(String text,
                             com.aspose.ms.System.Drawing.PointF pt)

        Fills the specified text string at the specified location.

        Specified by:
        fillText in interface IDevice
        Specified by:
        fillText in class Device<ImageGraphicContext,ImageRenderingOptions>
        Parameters:
        text - String to fill.
        pt - Point that specifies the coordinates of the text.
      • strokeText

        public void strokeText(String text,
                               com.aspose.ms.System.Drawing.PointF pt)

        Strokes the specified text string at the specified location.

        Specified by:
        strokeText in interface IDevice
        Specified by:
        strokeText in class Device<ImageGraphicContext,ImageRenderingOptions>
        Parameters:
        text - String to stroke.
        pt - Point that specifies the coordinates where to start the text.
      • drawImage

        public void drawImage(byte[] data,
                              int type,
                              com.aspose.ms.System.Drawing.RectangleF rect)

        Draws the specified image.

        Specified by:
        drawImage in interface IDevice
        Specified by:
        drawImage in class Device<ImageGraphicContext,ImageRenderingOptions>
        Parameters:
        data - An array of bytes representing the image.
        type - Image type.
        rect - A rectangel which determines position and size to draw.
      • getInternalOutputStream

        public com.aspose.ms.System.IO.Stream getInternalOutputStream()
      • getInternalPageIndex

        public int getInternalPageIndex()
      • getGraphics

        public com.aspose.ms.System.Drawing.Graphics getGraphics()

        Gets the instance of Graphics.

      • getGraphicContextClass

        public Class<? extends GraphicContext> getGraphicContextClass()
        Description copied from interface: IDevice

        Pushes a copy of the entire graphics context onto the stack.

      • beginPage

        public void beginPage(com.aspose.ms.System.Drawing.SizeF size)

        Begins rendering of the new page.

        Specified by:
        beginPage in interface IDevice
        Overrides:
        beginPage in class Device<ImageGraphicContext,ImageRenderingOptions>
        Parameters:
        size - Size of the page.