Genuts API

com.genuts.gameui.image
Class PictureExtractor

java.lang.Object
  extended bycom.genuts.gameui.image.PictureExtractor

public class PictureExtractor
extends java.lang.Object

Extracts all pictures from a given image.
The background color is designed by the point on coordinates (0,0) of the image, and the border color of pictures is found with the first angle of the same color.
The order of returning pictures is given from the left to the right, and from top to bottom.

For example, the following image contains 3 pictures:

In order, you will receive:

Picture 0
Picture 1
Picture 2
Picture 3
Picture 4
Picture 5

Of course, you can and it is recommended to arrange pictures to loose less as possible space in the image, the size depend of it.

For compatibility reason with JDK 1.1, transparent color is not preserved, we recommend you to use TransparentColorFilter class for this purpose.


Constructor Summary
PictureExtractor(java.awt.Component component)
          Creates the picture extractor.
 
Method Summary
 java.awt.Image[] getAllPictures(java.awt.Image image)
          Extracts all pictures from an image.
 java.awt.Image[] getAllPictures(java.lang.String file)
          Extracts all pictures from an image file.
 java.awt.Image[] getAllPictures(java.net.URL url)
          Extracts all pictures from an url.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PictureExtractor

public PictureExtractor(java.awt.Component component)
Creates the picture extractor.

Parameters:
component - A visible component to use for image manipulation.
Method Detail

getAllPictures

public java.awt.Image[] getAllPictures(java.lang.String file)
Extracts all pictures from an image file.

Parameters:
file - The image file from which pictures are extracted
Returns:
An array of images, or null if there is no picture found.

getAllPictures

public java.awt.Image[] getAllPictures(java.net.URL url)
Extracts all pictures from an url.

Parameters:
url - The url from which pictures are extracted.
Returns:
An array of images, or null if there is no picture found.

getAllPictures

public java.awt.Image[] getAllPictures(java.awt.Image image)
Extracts all pictures from an image.

Parameters:
image - The image from which pictures are extracted
Returns:
An array of images, or null if there is no picture found.

Genuts API

Genuts API