|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.j3d.utils.image.TextureLoader
public class TextureLoader
This class is used for loading a texture from an Image or BufferedImage. The Image I/O API is used to load the images. (If the JAI IIO Tools package is available, a larger set of formats can be loaded, including TIFF, JPEG2000, and so on.) Methods are provided to retrieve the Texture object and the associated ImageComponent object or a scaled version of the ImageComponent object. Default format is RGBA. Other legal formats are: RGBA, RGBA4, RGB5_A1, RGB, RGB4, RGB5, R3_G3_B2, LUM8_ALPHA8, LUM4_ALPHA4, LUMINANCE and ALPHA
Field Summary | |
---|---|
static int |
ALLOW_NON_POWER_OF_TWO
Optional flag - specifies that the ImageComponent2D is allowed to have dimensions that are not a power of two. |
private static int[] |
bandOffset
|
private java.awt.image.BufferedImage |
bufferedImage
|
static int |
BY_REFERENCE
Optional flag - specifies that the ImageComponent2D will access the image data by reference |
private boolean |
byRef
|
private static java.awt.image.ComponentColorModel |
colorModel
|
private static java.awt.color.ColorSpace |
cs
|
private int |
flags
|
private boolean |
forcePowerOfTwo
|
static int |
GENERATE_MIPMAP
Optional flag - specifies that mipmaps are generated for all levels |
private ImageComponent2D |
imageComponent
|
private int |
imageComponentFormat
|
private static int[] |
nBits
|
private Texture2D |
tex
|
private int |
textureFormat
|
static int |
Y_UP
Optional flag - specifies that the ImageComponent2D will have a y-orientation of y up, meaning the origin of the image is the lower left |
private boolean |
yUp
|
Constructor Summary | |
---|---|
TextureLoader(java.awt.image.BufferedImage bImage)
Contructs a TextureLoader object using the specified BufferedImage and default format RGBA |
|
TextureLoader(java.awt.image.BufferedImage bImage,
int flags)
Contructs a TextureLoader object using the specified BufferedImage, option flags and default format RGBA |
|
TextureLoader(java.awt.image.BufferedImage bImage,
java.lang.String format)
Contructs a TextureLoader object using the specified BufferedImage and format |
|
TextureLoader(java.awt.image.BufferedImage bImage,
java.lang.String format,
int flags)
Contructs a TextureLoader object using the specified BufferedImage, format and option flags |
|
TextureLoader(java.awt.Image image,
java.awt.Component observer)
Contructs a TextureLoader object using the specified Image and default format RGBA |
|
TextureLoader(java.awt.Image image,
int flags,
java.awt.Component observer)
Contructs a TextureLoader object using the specified Image flags and default format RGBA |
|
TextureLoader(java.awt.Image image,
java.lang.String format,
java.awt.Component observer)
Contructs a TextureLoader object using the specified Image and format |
|
TextureLoader(java.awt.Image image,
java.lang.String format,
int flags,
java.awt.Component observer)
Contructs a TextureLoader object using the specified Image format and option flags |
|
TextureLoader(java.lang.String fname,
java.awt.Component observer)
Contructs a TextureLoader object using the specified file and default format RGBA |
|
TextureLoader(java.lang.String fname,
int flags,
java.awt.Component observer)
Contructs a TextureLoader object using the specified file, option flags and default format RGBA |
|
TextureLoader(java.lang.String fname,
java.lang.String format,
java.awt.Component observer)
Contructs a TextureLoader object using the specified file, and format |
|
TextureLoader(java.lang.String fname,
java.lang.String format,
int flags,
java.awt.Component observer)
Contructs a TextureLoader object using the specified file, format and option flags |
|
TextureLoader(java.net.URL url,
java.awt.Component observer)
Contructs a TextureLoader object using the specified URL and default format RGBA |
|
TextureLoader(java.net.URL url,
int flags,
java.awt.Component observer)
Contructs a TextureLoader object using the specified URL, option flags and default format RGBA |
|
TextureLoader(java.net.URL url,
java.lang.String format,
java.awt.Component observer)
Contructs a TextureLoader object using the specified URL, and format |
|
TextureLoader(java.net.URL url,
java.lang.String format,
int flags,
java.awt.Component observer)
Contructs a TextureLoader object using the specified URL, format and option flags |
Method Summary | |
---|---|
private void |
chooseFormat(java.awt.image.BufferedImage image)
Choose the correct ImageComponent and Texture format for the given image |
private int |
computeLog(int value)
|
private java.awt.image.BufferedImage |
createBufferedImage(java.awt.Image image,
java.awt.Component observer)
|
private int |
getClosestPowerOf2(int value)
|
ImageComponent2D |
getImage()
Returns the associated ImageComponent2D object |
private int |
getImageType(java.awt.image.RenderedImage ri)
|
private java.awt.image.BufferedImage |
getScaledImage(java.awt.image.BufferedImage origImage,
float xScale,
float yScale)
|
private java.awt.image.BufferedImage |
getScaledImage(java.awt.image.BufferedImage origImage,
int width,
int height)
|
ImageComponent2D |
getScaledImage(float xScale,
float yScale)
Returns the scaled ImageComponent2D object |
ImageComponent2D |
getScaledImage(int width,
int height)
Returns the scaled ImageComponent2D object |
Texture |
getTexture()
Returns the associated Texture object. |
private boolean |
is4ByteRGBAOr3ByteRGB(java.awt.image.RenderedImage ri)
|
private void |
parseFormat(java.lang.String format)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int GENERATE_MIPMAP
public static final int BY_REFERENCE
public static final int Y_UP
public static final int ALLOW_NON_POWER_OF_TWO
Note that non-power-of-two textures may not be supported by all graphics
cards. Applications should check whether a particular Canvas3D supports
non-power-of-two textures by calling the Canvas3D.queryProperties()
method, and checking whether the
textureNonPowerOfTwoAvailable
property is set to true.
private static java.awt.color.ColorSpace cs
private static int[] nBits
private static int[] bandOffset
private static java.awt.image.ComponentColorModel colorModel
private Texture2D tex
private java.awt.image.BufferedImage bufferedImage
private ImageComponent2D imageComponent
private int textureFormat
private int imageComponentFormat
private int flags
private boolean byRef
private boolean yUp
private boolean forcePowerOfTwo
Constructor Detail |
---|
public TextureLoader(java.awt.image.BufferedImage bImage)
bImage
- The BufferedImage used for loading the texture
java.lang.NullPointerException
- if bImage is nullpublic TextureLoader(java.awt.image.BufferedImage bImage, java.lang.String format)
bImage
- The BufferedImage used for loading the textureformat
- The format specifies which channels to use
java.lang.NullPointerException
- if bImage is nullpublic TextureLoader(java.awt.image.BufferedImage bImage, int flags)
bImage
- The BufferedImage used for loading the textureflags
- The flags specify what options to use in texture loading (generate mipmap etc)
java.lang.NullPointerException
- if bImage is nullpublic TextureLoader(java.awt.image.BufferedImage bImage, java.lang.String format, int flags)
bImage
- The BufferedImage used for loading the textureformat
- The format specifies which channels to useflags
- The flags specify what options to use in texture loading (generate mipmap etc)
java.lang.NullPointerException
- if bImage is nullpublic TextureLoader(java.awt.Image image, java.awt.Component observer)
image
- The Image used for loading the textureobserver
- The associated image observer
java.lang.NullPointerException
- if image is null
ImageException
- if there is a problem loading the imagepublic TextureLoader(java.awt.Image image, java.lang.String format, java.awt.Component observer)
image
- The Image used for loading the textureformat
- The format specifies which channels to useobserver
- The associated image observer
java.lang.NullPointerException
- if image is null
ImageException
- if there is a problem loading the imagepublic TextureLoader(java.awt.Image image, int flags, java.awt.Component observer)
image
- The Image used for loading the textureflags
- The flags specify what options to use in texture loading (generate mipmap etc)observer
- The associated image observer
java.lang.NullPointerException
- if image is null
ImageException
- if there is a problem loading the imagepublic TextureLoader(java.awt.Image image, java.lang.String format, int flags, java.awt.Component observer)
image
- The Image used for loading the textureformat
- The format specifies which channels to useflags
- The flags specify what options to use in texture loading (generate mipmap etc)observer
- The associated image observer
java.lang.NullPointerException
- if image is null
ImageException
- if there is a problem loading the imagepublic TextureLoader(java.lang.String fname, java.awt.Component observer)
fname
- The file that specifies an Image to load the texture withobserver
- The associated image observer
ImageException
- if there is a problem reading the imagepublic TextureLoader(java.lang.String fname, java.lang.String format, java.awt.Component observer)
fname
- The file that specifies an Image to load the texture withformat
- The format specifies which channels to useobserver
- The associated image observer
ImageException
- if there is a problem reading the imagepublic TextureLoader(java.lang.String fname, int flags, java.awt.Component observer)
fname
- The file that specifies an Image to load the texture withflags
- The flags specify what options to use in texture loading (generate mipmap etc)observer
- The associated image observer
ImageException
- if there is a problem reading the imagepublic TextureLoader(java.lang.String fname, java.lang.String format, int flags, java.awt.Component observer)
fname
- The file that specifies an Image to load the texture withformat
- The format specifies which channels to useflags
- The flags specify what options to use in texture loading (generate mipmap etc)observer
- The associated image observer
ImageException
- if there is a problem reading the imagepublic TextureLoader(java.net.URL url, java.awt.Component observer)
url
- The URL that specifies an Image to load the texture withobserver
- The associated image observer
ImageException
- if there is a problem reading the imagepublic TextureLoader(java.net.URL url, java.lang.String format, java.awt.Component observer)
url
- The URL that specifies an Image to load the texture withformat
- The format specifies which channels to useobserver
- The associated image observer
ImageException
- if there is a problem reading the imagepublic TextureLoader(java.net.URL url, int flags, java.awt.Component observer)
url
- The URL that specifies an Image to load the texture withflags
- The flags specify what options to use in texture loading (generate mipmap etc)observer
- The associated image observer
ImageException
- if there is a problem reading the imagepublic TextureLoader(java.net.URL url, java.lang.String format, int flags, java.awt.Component observer)
url
- The url that specifies an Image to load the texture withformat
- The format specifies which channels to useflags
- The flags specify what options to use in texture loading (generate mipmap etc)observer
- The associated image observer
ImageException
- if there is a problem reading the imageMethod Detail |
---|
public ImageComponent2D getImage()
public ImageComponent2D getScaledImage(float xScale, float yScale)
xScale
- The X scaling factoryScale
- The Y scaling factor
public ImageComponent2D getScaledImage(int width, int height)
width
- The desired widthheight
- The desired height
public Texture getTexture()
private java.awt.image.BufferedImage createBufferedImage(java.awt.Image image, java.awt.Component observer)
private void chooseFormat(java.awt.image.BufferedImage image)
private boolean is4ByteRGBAOr3ByteRGB(java.awt.image.RenderedImage ri)
private int getImageType(java.awt.image.RenderedImage ri)
private void parseFormat(java.lang.String format)
private java.awt.image.BufferedImage getScaledImage(java.awt.image.BufferedImage origImage, int width, int height)
private java.awt.image.BufferedImage getScaledImage(java.awt.image.BufferedImage origImage, float xScale, float yScale)
private int computeLog(int value)
private int getClosestPowerOf2(int value)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |