Package com.sun.j3d.utils.image
Class TextureLoader
java.lang.Object
com.sun.j3d.utils.image.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
FieldsModifier and TypeFieldDescriptionstatic final int
Optional flag - specifies that the ImageComponent2D is allowed to have dimensions that are not a power of two.static final int
Optional flag - specifies that the ImageComponent2D will access the image data by referencestatic final int
Optional flag - specifies that mipmaps are generated for all levelsstatic final int
Optional flag - specifies that the ImageComponent2D will have a y-orientation of y up, meaning the origin of the image is the lower left -
Constructor Summary
ConstructorsConstructorDescriptionTextureLoader
(BufferedImage bImage) Contructs a TextureLoader object using the specified BufferedImage and default format RGBATextureLoader
(BufferedImage bImage, int flags) Contructs a TextureLoader object using the specified BufferedImage, option flags and default format RGBATextureLoader
(BufferedImage bImage, String format) Contructs a TextureLoader object using the specified BufferedImage and formatTextureLoader
(BufferedImage bImage, String format, int flags) Contructs a TextureLoader object using the specified BufferedImage, format and option flagsTextureLoader
(Image image, int flags, Component observer) Contructs a TextureLoader object using the specified Image flags and default format RGBATextureLoader
(Image image, Component observer) Contructs a TextureLoader object using the specified Image and default format RGBATextureLoader
(Image image, String format, int flags, Component observer) Contructs a TextureLoader object using the specified Image format and option flagsTextureLoader
(Image image, String format, Component observer) Contructs a TextureLoader object using the specified Image and formatTextureLoader
(String fname, int flags, Component observer) Contructs a TextureLoader object using the specified file, option flags and default format RGBATextureLoader
(String fname, Component observer) Contructs a TextureLoader object using the specified file and default format RGBATextureLoader
(String fname, String format, int flags, Component observer) Contructs a TextureLoader object using the specified file, format and option flagsTextureLoader
(String fname, String format, Component observer) Contructs a TextureLoader object using the specified file, and formatTextureLoader
(URL url, int flags, Component observer) Contructs a TextureLoader object using the specified URL, option flags and default format RGBATextureLoader
(URL url, Component observer) Contructs a TextureLoader object using the specified URL and default format RGBATextureLoader
(URL url, String format, int flags, Component observer) Contructs a TextureLoader object using the specified URL, format and option flagsTextureLoader
(URL url, String format, Component observer) Contructs a TextureLoader object using the specified URL, and format -
Method Summary
Modifier and TypeMethodDescriptiongetImage()
Returns the associated ImageComponent2D objectgetScaledImage
(float xScale, float yScale) Returns the scaled ImageComponent2D objectgetScaledImage
(int width, int height) Returns the scaled ImageComponent2D objectReturns the associated Texture object.
-
Field Details
-
GENERATE_MIPMAP
public static final int GENERATE_MIPMAPOptional flag - specifies that mipmaps are generated for all levels- See Also:
-
BY_REFERENCE
public static final int BY_REFERENCEOptional flag - specifies that the ImageComponent2D will access the image data by reference- Since:
- Java 3D 1.2
- See Also:
-
Y_UP
public static final int Y_UPOptional flag - specifies that the ImageComponent2D will have a y-orientation of y up, meaning the origin of the image is the lower left- Since:
- Java 3D 1.2
- See Also:
-
ALLOW_NON_POWER_OF_TWO
public static final int ALLOW_NON_POWER_OF_TWOOptional flag - specifies that the ImageComponent2D is allowed to have dimensions that are not a power of two. If this flag is set, TextureLoader will not perform any scaling of images. If this flag is not set, images will be scaled to the nearest power of two. This is the default mode.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 thetextureNonPowerOfTwoAvailable
property is set to true.- Since:
- Java 3D 1.5
- See Also:
-
-
Constructor Details
-
TextureLoader
Contructs a TextureLoader object using the specified BufferedImage and default format RGBA- Parameters:
bImage
- The BufferedImage used for loading the texture- Throws:
NullPointerException
- if bImage is null
-
TextureLoader
Contructs a TextureLoader object using the specified BufferedImage and format- Parameters:
bImage
- The BufferedImage used for loading the textureformat
- The format specifies which channels to use- Throws:
NullPointerException
- if bImage is null
-
TextureLoader
Contructs a TextureLoader object using the specified BufferedImage, option flags and default format RGBA- Parameters:
bImage
- The BufferedImage used for loading the textureflags
- The flags specify what options to use in texture loading (generate mipmap etc)- Throws:
NullPointerException
- if bImage is null
-
TextureLoader
Contructs a TextureLoader object using the specified BufferedImage, format and option flags- Parameters:
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)- Throws:
NullPointerException
- if bImage is null
-
TextureLoader
Contructs a TextureLoader object using the specified Image and default format RGBA- Parameters:
image
- The Image used for loading the textureobserver
- The associated image observer- Throws:
NullPointerException
- if image is nullImageException
- if there is a problem loading the image
-
TextureLoader
Contructs a TextureLoader object using the specified Image and format- Parameters:
image
- The Image used for loading the textureformat
- The format specifies which channels to useobserver
- The associated image observer- Throws:
NullPointerException
- if image is nullImageException
- if there is a problem loading the image
-
TextureLoader
Contructs a TextureLoader object using the specified Image flags and default format RGBA- Parameters:
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- Throws:
NullPointerException
- if image is nullImageException
- if there is a problem loading the image
-
TextureLoader
Contructs a TextureLoader object using the specified Image format and option flags- Parameters:
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- Throws:
NullPointerException
- if image is nullImageException
- if there is a problem loading the image
-
TextureLoader
Contructs a TextureLoader object using the specified file and default format RGBA- Parameters:
fname
- The file that specifies an Image to load the texture withobserver
- The associated image observer- Throws:
ImageException
- if there is a problem reading the image
-
TextureLoader
Contructs a TextureLoader object using the specified file, and format- Parameters:
fname
- The file that specifies an Image to load the texture withformat
- The format specifies which channels to useobserver
- The associated image observer- Throws:
ImageException
- if there is a problem reading the image
-
TextureLoader
Contructs a TextureLoader object using the specified file, option flags and default format RGBA- Parameters:
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- Throws:
ImageException
- if there is a problem reading the image
-
TextureLoader
Contructs a TextureLoader object using the specified file, format and option flags- Parameters:
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- Throws:
ImageException
- if there is a problem reading the image
-
TextureLoader
Contructs a TextureLoader object using the specified URL and default format RGBA- Parameters:
url
- The URL that specifies an Image to load the texture withobserver
- The associated image observer- Throws:
ImageException
- if there is a problem reading the image
-
TextureLoader
Contructs a TextureLoader object using the specified URL, and format- Parameters:
url
- The URL that specifies an Image to load the texture withformat
- The format specifies which channels to useobserver
- The associated image observer- Throws:
ImageException
- if there is a problem reading the image
-
TextureLoader
Contructs a TextureLoader object using the specified URL, option flags and default format RGBA- Parameters:
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- Throws:
ImageException
- if there is a problem reading the image
-
TextureLoader
Contructs a TextureLoader object using the specified URL, format and option flags- Parameters:
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- Throws:
ImageException
- if there is a problem reading the image
-
-
Method Details
-
getImage
Returns the associated ImageComponent2D object- Returns:
- The associated ImageComponent2D object
-
getScaledImage
Returns the scaled ImageComponent2D object- Parameters:
xScale
- The X scaling factoryScale
- The Y scaling factor- Returns:
- The scaled ImageComponent2D object
-
getScaledImage
Returns the scaled ImageComponent2D object- Parameters:
width
- The desired widthheight
- The desired height- Returns:
- The scaled ImageComponent2D object
-
getTexture
Returns the associated Texture object.- Returns:
- The associated Texture object
-