|
NASA World Wind | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectgov.nasa.worldwindx.examples.util.PowerOfTwoPaddedImage
public class PowerOfTwoPaddedImage
The PowerOfTwoPaddedImage class converts images with non-power-of-two dimensions to images with power-of-two dimensions. The original image is copied into a power-of-two image, where any pixels not covered by the original image are completely transparent. This is a useful property when converting images to OpenGL textures. Non-power-of-two textures are handled inconsistently by graphics hardware. Not all hardware supports them, and many that do lack full support for the the texturing functionality avialable for power-of-two textures.
PowerOfTwoPaddedImage provides accessors to the converted power-of-two image, the power-of-two image's width and height, and the original image's width and height.
| Field Summary | |
|---|---|
protected int |
height
|
protected BufferedImage |
image
|
protected int |
width
|
| Constructor Summary | |
|---|---|
protected |
PowerOfTwoPaddedImage(BufferedImage image,
int width,
int height)
|
| Method Summary | |
|---|---|
static PowerOfTwoPaddedImage |
fromBufferedImage(BufferedImage image)
Returns a new PowerOfTwoPaddedImage by converting the specified image to a new image with
power-of-two dimensions. |
static PowerOfTwoPaddedImage |
fromPath(String path)
Returns a new PowerOfTwoPaddedImage from the specified path, or null if the file referenced by
path cannot be read, or is not a readable image. |
int |
getOriginalHeight()
Returns the height of the original non-power-of-two image, in pixels. |
int |
getOriginalWidth()
Returns the width of the original non-power-of-two image, in pixels. |
int |
getPowerOfTwoHeight()
Returns the height of the power-of-two image, in pixels. |
BufferedImage |
getPowerOfTwoImage()
Returns a copy of the original image as a BufferedImage with power-of-two dimensions. |
int |
getPowerOfTwoWidth()
Returns the width of the power-of-two image, in pixels. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int height
protected BufferedImage image
protected int width
| Constructor Detail |
|---|
protected PowerOfTwoPaddedImage(BufferedImage image,
int width,
int height)
| Method Detail |
|---|
public static PowerOfTwoPaddedImage fromBufferedImage(BufferedImage image)
image to a new image with
power-of-two dimensions. Any pixels not covered by the original image are completely transparent. If the
specified image has power-of-two dimensions, this maintains a reference to the original image
instead of creating a copy. However, if the specified image has no alpha channel, this creates a
copy of the original image with an alpha channel, regardless of the specified image's dimensions.
This guarantees that the method getPowerOfTwoImage() always returns a BufferedImage with an alpha
channel. This is a useful property when converting images to OpenGL texture's, when both power-of-two and
non-power-of-two textures must have an alpha channel for consistent handling.
image - the BufferedImage to convert to an image with power-of-two dimensions.
image.
IllegalArgumentException - if the image is null.public static PowerOfTwoPaddedImage fromPath(String path)
path, or null if the file referenced by
path cannot be read, or is not a readable image. The path must be a local file path, or
a valid resource on the classpath. This uses ImageIO to read the specified
path as a BufferedImage. Otherwise, this treats the resultant BufferedImage
exactly as fromBufferedImage(java.awt.image.BufferedImage).
path - a local file path, or a valid resource on the classpath.
path, or null if the image file reference by path cannot be read.
IllegalArgumentException - if the path is null.public int getOriginalHeight()
public int getOriginalWidth()
public int getPowerOfTwoHeight()
public BufferedImage getPowerOfTwoImage()
BufferedImage with power-of-two dimensions. Any
pixels not covered by the original image are completely transparent.
public int getPowerOfTwoWidth()
|
NASA World Wind | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||