Xj3D 2.0 VRML/X3D Code API

org.xj3d.ui.swt.util
Class ImageUtils

java.lang.Object
  extended by org.xj3d.ui.swt.util.ImageUtils

public class ImageUtils
extends java.lang.Object

Utilities for processing SWT ImageData objects to be used as textures.

Version:
$Revision: 1.1 $
Author:
Rex Melton

Constructor Summary
ImageUtils()
          Constructor
ImageUtils(boolean imageScaleUp, boolean useMipMaps, int maxTextureSize)
          Constructor
 
Method Summary
 NIOBufferImage consolidate(org.eclipse.swt.graphics.ImageData[] imageArray)
          Convert the ImageData objects into NIOBufferImages and extract the individual image byte buffers from the resulting NIOBufferImages and consolidate them into a single byte buffer array in the returned NIOBufferImage.
 org.eclipse.swt.graphics.ImageData[] preprocess(org.eclipse.swt.graphics.ImageData image)
          Scale and create mipmaps of the argument image.
 org.eclipse.swt.graphics.ImageData scale(org.eclipse.swt.graphics.ImageData image, int width, int height)
          Return a new ImageData object scaled from the argument ImageDatato the specified width and height.
 NIOBufferImage toNIOBufferImage(org.eclipse.swt.graphics.ImageData image)
          Return an NIOBufferImage representation of the argument image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageUtils

public ImageUtils()
Constructor


ImageUtils

public ImageUtils(boolean imageScaleUp,
                  boolean useMipMaps,
                  int maxTextureSize)
Constructor

Parameters:
imageScaleUp - Flag indicating how image rescales should be handled. true if the image should be rescaled up to the nearest power of two, false if the image should be rescaled down to the nearest power of two.
useMipMaps - Flag indicating whether to create mipmaps when processing an image.
maxTextureSize - The maximum texture size per dimension, must be a power of two. A negative integer allows an unlimited image size. A positive non-power of two integer will be converted to the nearest smaller power of two.
Method Detail

toNIOBufferImage

public NIOBufferImage toNIOBufferImage(org.eclipse.swt.graphics.ImageData image)
Return an NIOBufferImage representation of the argument image.

Parameters:
image - The image to covert
Returns:
The NIOBufferImage representation

preprocess

public org.eclipse.swt.graphics.ImageData[] preprocess(org.eclipse.swt.graphics.ImageData image)
Scale and create mipmaps of the argument image. The initial image will be resized as necessary to dimensions that are a power of 2 and less than or equal to the maximum size (if defined). Mipmaps will be generated as specified from the resized initial image and the array of images returned.

Parameters:
image - The initial image
Returns:
The array containing the scaled image and it's mipmaps

consolidate

public NIOBufferImage consolidate(org.eclipse.swt.graphics.ImageData[] imageArray)
Convert the ImageData objects into NIOBufferImages and extract the individual image byte buffers from the resulting NIOBufferImages and consolidate them into a single byte buffer array in the returned NIOBufferImage. This is used to place the rescaled image and it's mipmaps into a single container.

Parameters:
imageArray - The primary image and set of mipmaps
Returns:
The consolidated NIOBufferImage

scale

public org.eclipse.swt.graphics.ImageData scale(org.eclipse.swt.graphics.ImageData image,
                                                int width,
                                                int height)
Return a new ImageData object scaled from the argument ImageDatato the specified width and height. If the argument is already the specified size, it will be returned unchanged.

Parameters:
image - The image to scale
width - The width for the new image
height - The height of the new image
Returns:
An ImageData sized as requested

Xj3D 2.0 VRML/X3D Code API

Copyright © 2001 - 2006 Web3D Consortium