Image Viewing & Manupilation

showImage(Image image {, int width, int height } )

showImage() displays an image in a window. When width and height are specified and the image size is larger than that, a scroll bar appears within the frame.

e.g.
im = getToolkit().getImage("test.jpg")
showImage(im)
readImage(InputStream input { , String mimeType } ) or
(URL url { , String mimeType } ) or
(String path { , String mimeType } )

readImage() reads an image from file, URL, or InputStream.

e.g.
im = readImage("test.png")
showImage(im)

This function requires Image I/O API, which is a part of JDK1.4.

writeImage(Image image, String path ) or
(Image image, File file ) or
(Image image, String mimeType, OutputStream output )

writeImage() writes the specified image to a file or an OutputStream.

e.g.
im = readImage("test.png")
writeImage(im, "test.bmp")

This function requires Image I/O API, which is a part of JDK1.4.X.

makeImage(int width, int height, PnutsFunction drawFunc {, int imageType })

A Image object of the size width x height is created and the function drawFunc is called to draw something, if it is not null.

drawFunc(Graphics graphics)

imageType can be one of the following constants:

e.g.
import("java.awt.Color")
im = makeImage(100, 100, function (g){
        g.setColor(Color::white)
        g.fillRect(0, 0, 100, 100)
        g.setColor(Color::blue)
        g.fillOval(0, 0, 100, 100)
     }, TYPE_INT_RGB)
showImage(im)
filterImage(Image image, ImageFilter imageFilter )

filterImage() returns an image created by filtering the image with the imageFilter.

cropImage(Image image, int x, int y, int w, int h)

cropImage() crops the rectangular region (x, y, x + w, y + h) of the image.

scaleImage(Image image, double x, double y)

scaleImage() transform the image with the scaling factor x and y.

rotateImage(Image image, double theta {, double x,double y} )

rotateImage() rotates the image with a positive angle theta and rotates points (x, y).

flipImage(Image image, boolean horizontal, boolean vertical)

flipImage() flips the image vertically, if vertical is true, and horizontally , if horizontal is true.

shearImage(Image image, double x, double y)

shearImage() applies shearing transformation to image.

grayImage(Image image)

grayImage() converts image to a gray scale image.