diff options
author | Sven Gothel <[email protected]> | 2013-04-27 01:38:12 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-04-27 01:38:12 +0200 |
commit | 94ea306d1809290db678d3181619bdc39d4334bb (patch) | |
tree | cd61bb347f6980dbdc5d2aac86f59b4261c1325e | |
parent | ff9fb2d0adc81fdf25d6e26b91e1f67d8241e3e4 (diff) |
Move JPEGDecoder.PixelStorage -> TextureData.ColorSink: Appropriate name + public use
3 files changed, 22 insertions, 20 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java index 5b72bea82..15b8930bb 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java @@ -56,6 +56,21 @@ import com.jogamp.opengl.util.GLBuffers; public class TextureData { public static enum ColorSpace { RGB, YCbCr, YCCK, CMYK }; + public static interface ColorSink { + /** + * @param width + * @param height + * @param sourceCS the color-space of the decoded JPEG + * @param sourceComponents number of components used for the given source color-space + * @return Either {@link ColorSpace#RGB} or {@link ColorSpace#YCbCr}. {@link ColorSpace#YCCK} and {@link ColorSpace#CMYK} will throw an exception! + * @throws RuntimeException + */ + public ColorSpace allocate(int width, int height, ColorSpace sourceCS, int sourceComponents) throws RuntimeException; + public void store2(int x, int y, byte c1, byte c2); + public void storeRGB(int x, int y, byte r, byte g, byte b); + public void storeYCbCr(int x, int y, byte Y, byte Cb, byte Cr); + } + protected int width; protected int height; private int border; diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java index 71dd53939..14253e4af 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java @@ -38,6 +38,7 @@ import jogamp.opengl.util.jpeg.JPEGDecoder; import com.jogamp.common.nio.Buffers; import com.jogamp.opengl.util.texture.TextureData.ColorSpace; +import com.jogamp.opengl.util.texture.TextureData.ColorSink; public class JPEGImage { private static final boolean DEBUG = Debug.debug("JPEGImage"); @@ -60,7 +61,7 @@ public class JPEGImage { return new JPEGImage(in, ColorSpace.RGB); } - private static class JPEGPixelStorage implements JPEGDecoder.PixelStorage { + private static class JPEGColorSink implements ColorSink { int width=0, height=0; int sourceComponents=0; ColorSpace sourceCS = ColorSpace.YCbCr; @@ -68,7 +69,7 @@ public class JPEGImage { final ColorSpace storageCS; ByteBuffer data = null; - JPEGPixelStorage(ColorSpace storageCM) { + JPEGColorSink(ColorSpace storageCM) { this.storageCS = storageCM; switch(storageCS) { case RGB: @@ -118,7 +119,7 @@ public class JPEGImage { }; private JPEGImage(InputStream in, ColorSpace cs) throws IOException { - pixelStorage = new JPEGPixelStorage(cs); + pixelStorage = new JPEGColorSink(cs); final JPEGDecoder decoder = new JPEGDecoder(); decoder.parse(in); pixelWidth = decoder.getWidth(); @@ -138,7 +139,7 @@ public class JPEGImage { } decoder.clear(null); } - private JPEGPixelStorage pixelStorage; + private JPEGColorSink pixelStorage; private final int pixelWidth, pixelHeight, glFormat, bytesPerPixel; private boolean reversedChannels; private final ByteBuffer data; diff --git a/src/jogl/classes/jogamp/opengl/util/jpeg/JPEGDecoder.java b/src/jogl/classes/jogamp/opengl/util/jpeg/JPEGDecoder.java index 748e70d5b..8df147405 100644 --- a/src/jogl/classes/jogamp/opengl/util/jpeg/JPEGDecoder.java +++ b/src/jogl/classes/jogamp/opengl/util/jpeg/JPEGDecoder.java @@ -67,6 +67,7 @@ import jogamp.opengl.Debug; import com.jogamp.common.util.ArrayHashSet; import com.jogamp.common.util.VersionNumber; import com.jogamp.opengl.util.texture.TextureData.ColorSpace; +import com.jogamp.opengl.util.texture.TextureData.ColorSink; /** * @@ -88,21 +89,6 @@ public class JPEGDecoder { private static final boolean DEBUG = Debug.debug("JPEGImage"); private static final boolean DEBUG_IN = false; - public static interface PixelStorage { - /** - * @param width - * @param height - * @param sourceCS the color-space of the decoded JPEG - * @param sourceComponents number of components used for the given source color-space - * @return Either {@link ColorSpace#RGB} or {@link ColorSpace#YCbCr}. {@link ColorSpace#YCCK} and {@link ColorSpace#CMYK} will throw an exception! - * @throws RuntimeException - */ - public ColorSpace allocate(int width, int height, ColorSpace sourceCS, int sourceComponents) throws RuntimeException; - public void store2(int x, int y, byte c1, byte c2); - public void storeRGB(int x, int y, byte r, byte g, byte b); - public void storeYCbCr(int x, int y, byte Y, byte Cb, byte Cr); - } - public static class JFIF { final VersionNumber version; final int densityUnits; @@ -1347,7 +1333,7 @@ public class JPEGDecoder { pixelStorage.storeRGB(x, y, (byte)R, (byte)G, (byte)B); } */ - public synchronized void getPixel(PixelStorage pixelStorage, int width, int height) { + public synchronized void getPixel(ColorSink pixelStorage, int width, int height) { final int scaleX = this.width / width, scaleY = this.height / height; final int componentCount = this.components.length; |