Drawing Images

Published

The following sections cover the constructor and functions of the ImagePrinter class.

Links

Images(BufferedImage)

This constructor creates a new, reusable ImagePrinter.

Like EllipsePrinters, LinePrinters, and RectanglePrinters, ImagePrinters can be reused. However, an ImagePrinter is only ever able to print the image that it was constructed to print. Thie means that you can reuse the ImagePrinter to print as many copies of the source image as you desire, but you must create another ImagePrinter when you want to print a different image.

The following example shows that you do not need to create a new instance of the ImagePrinter class for each copy of the source image that you print.

print(TileGrid, Point)

This function prints an image on a TileGrid. The point given is the top-left point/tile of the image.

With this function, each pixel of the source image is mapped to 1 vertical and 2 horizontal tiles on the TileGrid. This can be changed using the setScaleX(int) and setScaleY(int) functions.

printDetailed(TileGrid, Point)

This function prints an image on a TileGrid. The point given is the top-left point/tile of the image.

With this function, special characters are used to allow a single tile to represent a 2x2 grid of pixels. However, this added detail comes with a restriction on the type of source image that can be used. Each group of 2x2 pixel chunks, in the source image, can only make use of two unique colors. An example of an image, drawn with this restriction in-mind, can be found here.

As with the print(TileGrid, Point) function, each pixel of the source image is mapped to 1 vertical and 2 horizontal sub-tile pixels on the TileGrid. This can be changed using the setScaleX(int) and setScaleY(int) functions.

setScaleX(int)

This function sets the amount that the source image is scaled by, on the x-axis, before being drawn.

setScaleY(int)

This function sets the amount that the source image is scaled by, on the y-axis, before being drawn.


Return to Documentation