JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
IIOTextureProvider.java
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
3 * Copyright (c) 2015 JogAmp Community. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * - Redistribution of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * - Redistribution in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * Neither the name of Sun Microsystems, Inc. or the names of
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * This software is provided "AS IS," without a warranty of any kind. ALL
21 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
22 * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
23 * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
24 * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
25 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
26 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
27 * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
28 * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
29 * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
30 * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
31 * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 *
33 * You acknowledge that this software is not designed or intended for use
34 * in the design, construction, operation or maintenance of any nuclear
35 * facility.
36 *
37 * Sun gratefully acknowledges that this software was originally authored
38 * and developed by Kenneth Bradley Russell and Christopher John Kline.
39 */
40//
41package com.jogamp.opengl.util.texture.spi.awt;
42
43import java.awt.image.BufferedImage;
44import java.io.IOException;
45import java.io.InputStream;
46
47import javax.imageio.ImageIO;
48
49import com.jogamp.opengl.GLProfile;
50import com.jogamp.opengl.util.texture.ImageType;
51import com.jogamp.opengl.util.texture.TextureData;
52import com.jogamp.opengl.util.texture.awt.AWTTextureData;
53import com.jogamp.opengl.util.texture.spi.TextureProvider;
54
55import jogamp.opengl.Debug;
56
57public class IIOTextureProvider implements TextureProvider {
58 private static final boolean DEBUG = Debug.debug("TextureIO");
59
60 @Override
61 public final ImageType[] getImageTypes() {
62 return null;
63 }
64
65 @Override
66 public TextureData newTextureData(final GLProfile glp, final InputStream stream,
67 final int internalFormat,
68 final int pixelFormat,
69 final boolean mipmap,
70 final String fileSuffix) throws IOException {
71 final BufferedImage img = ImageIO.read(stream);
72 if (img == null) {
73 return null;
74 }
75 if (DEBUG) {
76 System.out.println("TextureIO.newTextureData(): BufferedImage type for stream = " +
77 img.getType());
78 }
79 return new AWTTextureData(glp, internalFormat, pixelFormat, mipmap, img);
80 }
81}
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
Image type classification.
Definition: ImageType.java:42
Represents the data for an OpenGL texture.
TextureData newTextureData(final GLProfile glp, final InputStream stream, final int internalFormat, final int pixelFormat, final boolean mipmap, final String fileSuffix)
Produces a TextureData object from a stream, or returns null if the file format was not supported by ...
final ImageType[] getImageTypes()
Returns the known supported ImageTypes, or null if unknown.
Plug-in interface to TextureIO to support reading OpenGL textures from new file formats.