Skip to content

Commit 2cd8aeb

Browse files
authored
Stb image loader (jMonkeyEngine#2718)
1 parent 2ecf7f9 commit 2cd8aeb

27 files changed

Lines changed: 182 additions & 15 deletions

File tree

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ nifty-style-black = { module = "com.github.nifty-gui:nifty-style-black",
4848
spotbugs-gradle-plugin = "com.github.spotbugs.snom:spotbugs-gradle-plugin:6.4.8"
4949
vecmath = "javax.vecmath:vecmath:1.5.2"
5050

51+
stb-image = "org.ngengine:stb-image:2.30.4"
52+
5153
[bundles]
5254

5355
[plugins]

jme3-android/src/main/resources/com/jme3/asset/Android.cfg

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ INCLUDE com/jme3/asset/General.cfg
33
# Android specific locators
44
LOCATOR / com.jme3.asset.plugins.AndroidLocator
55

6-
# Android specific loaders
7-
LOADER com.jme3.texture.plugins.AndroidNativeImageLoader : jpg, bmp, gif, png, jpeg
86
LOADER com.jme3.texture.plugins.AndroidBufferImageLoader : webp, heic, heif

jme3-core/src/main/java/com/jme3/texture/image/ImageCodec.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,21 @@ public ImageCodec(int bpp, int flags, int maxAlpha, int maxRed, int maxGreen, in
103103

104104
params.put(Format.RGB8, new ByteOffsetImageCodec(3, 0, -1, 0, 1, 2));
105105

106-
params.put(Format.RGB32F, new ByteAlignedImageCodec(12, FLAG_F32,
107-
0, 4, 4, 4,
108-
0, 0, 4, 8));
109-
110-
ByteAlignedImageCodec rgb16f = new ByteAlignedImageCodec(6, FLAG_F16,
111-
0, 2, 2, 2,
112-
0, 0, 2, 4);
106+
params.put(Format.RGB32F, new ByteAlignedImageCodec(12, FLAG_F32,
107+
0, 4, 4, 4,
108+
0, 0, 4, 8));
109+
110+
params.put(Format.R16F, new ByteAlignedImageCodec(2, FLAG_F16,
111+
0, 2, 0, 0,
112+
0, 0, 0, 0));
113+
114+
params.put(Format.RG16F, new ByteAlignedImageCodec(4, FLAG_F16,
115+
0, 2, 2, 0,
116+
0, 0, 2, 0));
117+
118+
ByteAlignedImageCodec rgb16f = new ByteAlignedImageCodec(6, FLAG_F16,
119+
0, 2, 2, 2,
120+
0, 0, 2, 4);
113121
params.put(Format.RGB16F, rgb16f);
114122
params.put(Format.RGB16F_to_RGB111110F, rgb16f);
115123
params.put(Format.RGB16F_to_RGB9E5, rgb16f);
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
INCLUDE com/jme3/asset/General.cfg
22

33
# Desktop-specific loaders
4-
LOADER com.jme3.texture.plugins.AWTLoader : jpg, bmp, gif, png, jpeg
54
LOADER com.jme3.cursors.plugins.CursorLoader : ani, cur, ico

jme3-core/src/main/resources/com/jme3/asset/General.cfg

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ LOADER com.jme3.material.plugins.ShaderNodeDefinitionLoader : j3sn
99
LOADER com.jme3.font.plugins.BitmapFontLoader : fnt
1010
LOADER com.jme3.texture.plugins.DDSLoader : dds
1111
LOADER com.jme3.texture.plugins.PFMLoader : pfm
12-
LOADER com.jme3.texture.plugins.HDRLoader : hdr
13-
LOADER com.jme3.texture.plugins.TGALoader : tga
1412
LOADER com.jme3.export.binary.BinaryLoader : j3o
1513
LOADER com.jme3.export.binary.BinaryLoader : j3f
1614
LOADER com.jme3.scene.plugins.OBJLoader : obj
@@ -23,4 +21,5 @@ LOADER com.jme3.shader.plugins.GLSLLoader : vert, frag, geom, tsctrl, tseval, gl
2321
LOADER com.jme3.scene.plugins.gltf.GltfLoader : gltf
2422
LOADER com.jme3.scene.plugins.gltf.BinLoader : bin
2523
LOADER com.jme3.scene.plugins.gltf.GlbLoader : glb
24+
LOADER com.jme3.texture.plugins.StbImageLoader : jpg, bmp, gif, png, jpeg, tga, psd, hdr
2625
LOADER com.jme3.audio.plugins.OGGLoader : ogg

jme3-core/src/plugins/java/com/jme3/texture/plugins/HDRLoader.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646
import java.util.logging.Level;
4747
import java.util.logging.Logger;
4848

49+
/**
50+
* @deprecated use {@link StbImageLoader} instead, which supports HDR images and more formats. This loader is
51+
* kept for backward compatibility but may be removed in future versions.
52+
*/
53+
@Deprecated
4954
public class HDRLoader implements AssetLoader {
5055

5156
private static final Logger logger = Logger.getLogger(HDRLoader.class.getName());

jme3-core/src/plugins/java/com/jme3/texture/plugins/TGALoader.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,16 @@
4646
import java.nio.ByteBuffer;
4747

4848
/**
49-
* <code>TextureManager</code> provides static methods for building a
50-
* <code>Texture</code> object. Typically, the information supplied is the
51-
* filename and the texture properties.
49+
* <code>TextureManager</code> provides static methods for building a <code>Texture</code> object. Typically,
50+
* the information supplied is the filename and the texture properties.
5251
*
5352
* @author Mark Powell
5453
* @author Joshua Slack - cleaned, commented, added ability to read 16bit true color and color-mapped TGAs.
5554
* @author Kirill Vainer - ported to jME3
5655
* @version $Id: TGALoader.java 4131 2009-03-19 20:15:28Z blaine.dev $
56+
* @deprecated use {@link StbImageLoader} instead
5757
*/
58+
@Deprecated
5859
public final class TGALoader implements AssetLoader {
5960

6061
// 0 - no image data in file

jme3-desktop/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
dependencies {
22
api project(':jme3-core')
3+
api project(':jme3-plugins')
34
}

jme3-desktop/src/main/java/com/jme3/texture/plugins/AWTLoader.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@
4747
import java.nio.ByteBuffer;
4848
import javax.imageio.ImageIO;
4949

50+
/**
51+
* @deprecated use {@link StbImageLoader} instead, which supports more formats and is more efficient and
52+
* platform agnostic. This loader is kept for backward compatibility but may be removed in future
53+
* versions.
54+
*/
55+
@Deprecated
5056
public class AWTLoader implements AssetLoader {
5157

5258
public static final ColorModel AWT_RGBA4444 = new DirectColorModel(16,

jme3-plugins/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ dependencies {
1414
implementation "org.jmonkeyengine:drako:1.4.5-jme"
1515
implementation project(':jme3-plugins-json')
1616
implementation project(':jme3-plugins-json-gson')
17+
implementation libs.stb.image
18+
1719
testRuntimeOnly project(':jme3-desktop')
1820
}

0 commit comments

Comments
 (0)