diff --git a/pom.xml b/pom.xml
index 7fb2c16..adeeb4c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,12 +65,6 @@
1.18.12
true
-
-
- org.scijava
- native-lib-loader
- 2.3.4
-
@@ -147,4 +141,4 @@
-
\ No newline at end of file
+
diff --git a/readme.md b/readme.md
index 5f149a2..944926f 100644
--- a/readme.md
+++ b/readme.md
@@ -20,9 +20,6 @@
- 滑动还原验证码
- 文字点选验证码
- 后面会陆续支持市面上更多好玩的验证码玩法... 敬请期待
-
-- 该滑块验证码实现了 普通图片和 **webp**(拷贝github大神开源的webp图片生成代码)图片两种格式
-
## 快速上手
如果是SpringBoot开发者可直接使用SpringBoot快速启动器[tianai-captcha-springboot-starter](https://gitee.com/tianai/tianai-captcha-springboot-starter)
@@ -309,4 +306,4 @@ public class Test {
}
}
```
-# qq群: 1021884609
\ No newline at end of file
+# qq群: 1021884609
diff --git a/src/main/java/com/luciad/imageio/webp/VP8StatusCode.java b/src/main/java/com/luciad/imageio/webp/VP8StatusCode.java
deleted file mode 100644
index 0d1047e..0000000
--- a/src/main/java/com/luciad/imageio/webp/VP8StatusCode.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2013 Luciad (http://www.luciad.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.luciad.imageio.webp;
-
-enum VP8StatusCode {
- VP8_STATUS_OK,
- VP8_STATUS_OUT_OF_MEMORY,
- VP8_STATUS_INVALID_PARAM,
- VP8_STATUS_BITSTREAM_ERROR,
- VP8_STATUS_UNSUPPORTED_FEATURE,
- VP8_STATUS_SUSPENDED,
- VP8_STATUS_USER_ABORT,
- VP8_STATUS_NOT_ENOUGH_DATA,;
-
- private static VP8StatusCode[] VALUES = values();
-
- public static VP8StatusCode getStatusCode( int aValue ) {
- if ( aValue >= 0 && aValue < VALUES.length ) {
- return VALUES[ aValue ];
- }
- else {
- return null;
- }
- }
-}
diff --git a/src/main/java/com/luciad/imageio/webp/WebP.java b/src/main/java/com/luciad/imageio/webp/WebP.java
deleted file mode 100644
index a8c78cb..0000000
--- a/src/main/java/com/luciad/imageio/webp/WebP.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2013 Luciad (http://www.luciad.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.luciad.imageio.webp;
-
-import lombok.extern.slf4j.Slf4j;
-import org.scijava.nativelib.DefaultJniExtractor;
-import org.scijava.nativelib.NativeLibraryUtil;
-
-import java.io.IOException;
-import java.nio.ByteOrder;
-
-@Slf4j
-final class WebP {
- private static boolean NATIVE_LIBRARY_LOADED = false;
-
- static synchronized void loadNativeLibrary() {
- if (!NATIVE_LIBRARY_LOADED) {
- NATIVE_LIBRARY_LOADED = true;
- try {
- NativeLibraryUtil.loadNativeLibrary(new DefaultJniExtractor(WebP.class), "webp-imageio");
- } catch (IOException e) {
- log.debug("IOException creating DefaultJniExtractor", e);
- }
- }
- }
-
- static {
- loadNativeLibrary();
- }
-
- private WebP() {
- }
-
- public static int[] decode(WebPDecoderOptions aOptions, byte[] aData, int aOffset, int aLength, int[] aOut) throws IOException {
- if (aOptions == null) {
- throw new NullPointerException("Decoder options may not be null");
- }
-
- if (aData == null) {
- throw new NullPointerException("Input data may not be null");
- }
-
- if (aOffset + aLength > aData.length) {
- throw new IllegalArgumentException("Offset/length exceeds array size");
- }
-
- int[] pixels = decode(aOptions.fPointer, aData, aOffset, aLength, aOut, ByteOrder.nativeOrder().equals(ByteOrder.BIG_ENDIAN));
- VP8StatusCode status = VP8StatusCode.getStatusCode(aOut[0]);
- switch (status) {
- case VP8_STATUS_OK:
- break;
- case VP8_STATUS_OUT_OF_MEMORY:
- throw new OutOfMemoryError();
- default:
- throw new IOException("Decode returned code " + status);
- }
-
- return pixels;
- }
-
- private static native int[] decode(long aDecoderOptionsPointer, byte[] aData, int aOffset, int aLength, int[] aFlags, boolean aBigEndian);
-
- public static int[] getInfo(byte[] aData, int aOffset, int aLength) throws IOException {
- int[] out = new int[2];
- int result = getInfo(aData, aOffset, aLength, out);
- if (result == 0) {
- throw new IOException("Invalid WebP data");
- }
-
- return out;
- }
-
- private static native int getInfo(byte[] aData, int aOffset, int aLength, int[] aOut);
-
- public static byte[] encodeRGBA(WebPEncoderOptions aOptions, byte[] aRgbaData, int aWidth, int aHeight, int aStride) {
- return encodeRGBA(aOptions.fPointer, aRgbaData, aWidth, aHeight, aStride);
- }
-
- private static native byte[] encodeRGBA(long aConfig, byte[] aRgbaData, int aWidth, int aHeight, int aStride);
-
- public static byte[] encodeRGB(WebPEncoderOptions aOptions, byte[] aRgbaData, int aWidth, int aHeight, int aStride) {
- return encodeRGB(aOptions.fPointer, aRgbaData, aWidth, aHeight, aStride);
- }
-
- private static native byte[] encodeRGB(long aConfig, byte[] aRgbaData, int aWidth, int aHeight, int aStride);
-}
diff --git a/src/main/java/com/luciad/imageio/webp/WebPDecoderOptions.java b/src/main/java/com/luciad/imageio/webp/WebPDecoderOptions.java
deleted file mode 100644
index 93153bb..0000000
--- a/src/main/java/com/luciad/imageio/webp/WebPDecoderOptions.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright 2013 Luciad (http://www.luciad.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.luciad.imageio.webp;
-
-public final class WebPDecoderOptions {
- static {
- WebP.loadNativeLibrary();
- }
-
- long fPointer;
-
- public WebPDecoderOptions() {
- fPointer = createDecoderOptions();
- if ( fPointer == 0 ) {
- throw new OutOfMemoryError();
- }
- }
-
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- deleteDecoderOptions( fPointer );
- fPointer = 0L;
- }
-
- public int getCropHeight() {
- return getCropHeight( fPointer );
- }
-
- public void setCropHeight( int aCropHeight ) {
- setCropHeight( fPointer, aCropHeight );
- }
-
- public int getCropLeft() {
- return getCropLeft( fPointer );
- }
-
- public void setCropLeft( int aCropLeft ) {
- setCropLeft( fPointer, aCropLeft );
- }
-
- public int getCropTop() {
- return getCropTop( fPointer );
- }
-
- public void setCropTop( int aCropTop ) {
- setCropTop( fPointer, aCropTop );
- }
-
- public int getCropWidth() {
- return getCropWidth( fPointer );
- }
-
- public void setCropWidth( int aCropWidth ) {
- setCropWidth( fPointer, aCropWidth );
- }
-
- public boolean isFancyUpsampling() {
- return !isNoFancyUpsampling( fPointer );
- }
-
- public void setFancyUpsampling( boolean aFancyUpsampling ) {
- setNoFancyUpsampling( fPointer, !aFancyUpsampling );
- }
-
- public int getScaledHeight() {
- return getScaledHeight( fPointer );
- }
-
- public void setScaledHeight( int aScaledHeight ) {
- setScaledHeight( fPointer, aScaledHeight );
- }
-
- public int getScaledWidth() {
- return getScaledWidth( fPointer );
- }
-
- public void setScaledWidth( int aScaledWidth ) {
- setScaledWidth( fPointer, aScaledWidth );
- }
-
- public boolean isUseCropping() {
- return isUseCropping( fPointer );
- }
-
- public void setUseCropping( boolean aUseCropping ) {
- setUseCropping( fPointer, aUseCropping );
- }
-
- public boolean isUseScaling() {
- return isUseScaling( fPointer );
- }
-
- public void setUseScaling( boolean aUseScaling ) {
- setUseScaling( fPointer, aUseScaling );
- }
-
- public boolean isUseThreads() {
- return isUseThreads( fPointer );
- }
-
- public void setUseThreads( boolean aUseThreads ) {
- setUseThreads( fPointer, aUseThreads );
- }
-
- public boolean isBypassFiltering() {
- return isBypassFiltering( fPointer );
- }
-
- public void setBypassFiltering( boolean aBypassFiltering ) {
- setBypassFiltering( fPointer, aBypassFiltering );
- }
-
- private static native long createDecoderOptions();
-
- private static native void deleteDecoderOptions( long aPointer );
-
- private static native int getCropHeight( long aPointer );
-
- private static native void setCropHeight( long aPointer, int aCropHeight );
-
- private static native int getCropLeft( long aPointer );
-
- private static native void setCropLeft( long aPointer, int aCropLeft );
-
- private static native int getCropTop( long aPointer );
-
- private static native void setCropTop( long aPointer, int aCropTop );
-
- private static native int getCropWidth( long aPointer );
-
- private static native void setCropWidth( long aPointer, int aCropWidth );
-
- private static native boolean isForceRotation( long aPointer );
-
- private static native void setForceRotation( long aPointer, boolean aForceRotation );
-
- private static native boolean isNoEnhancement( long aPointer );
-
- private static native void setNoEnhancement( long aPointer, boolean aNoEnhancement );
-
- private static native boolean isNoFancyUpsampling( long aPointer );
-
- private static native void setNoFancyUpsampling( long aPointer, boolean aFancyUpsampling );
-
- private static native int getScaledHeight( long aPointer );
-
- private static native void setScaledHeight( long aPointer, int aScaledHeight );
-
- private static native int getScaledWidth( long aPointer );
-
- private static native void setScaledWidth( long aPointer, int aScaledWidth );
-
- private static native boolean isUseCropping( long aPointer );
-
- private static native void setUseCropping( long aPointer, boolean aUseCropping );
-
- private static native boolean isUseScaling( long aPointer );
-
- private static native void setUseScaling( long aPointer, boolean aUseScaling );
-
- private static native boolean isUseThreads( long aPointer );
-
- private static native void setUseThreads( long aPointer, boolean aUseThreads );
-
- private static native boolean isBypassFiltering( long aPointer );
-
- private static native void setBypassFiltering( long aPointer, boolean aBypassFiltering );
-}
diff --git a/src/main/java/com/luciad/imageio/webp/WebPEncoderOptions.java b/src/main/java/com/luciad/imageio/webp/WebPEncoderOptions.java
deleted file mode 100644
index 9d83f63..0000000
--- a/src/main/java/com/luciad/imageio/webp/WebPEncoderOptions.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * Copyright 2013 Luciad (http://www.luciad.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.luciad.imageio.webp;
-
-public class WebPEncoderOptions {
- static {
- WebP.loadNativeLibrary();
- }
-
- long fPointer;
-
- public WebPEncoderOptions() {
- fPointer = createConfig();
- if ( fPointer == 0 ) {
- throw new OutOfMemoryError();
- }
- }
-
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- deleteConfig( fPointer );
- fPointer = 0L;
- }
-
- private static native long createConfig();
-
- private static native void deleteConfig( long aPointer );
-
- long getPointer() {
- return fPointer;
- }
-
- public float getCompressionQuality() {
- return getQuality(fPointer);
- }
-
- public void setCompressionQuality( float quality ) {
- setQuality( fPointer, quality );
- }
-
- public boolean isLossless() {
- return getLossless( fPointer ) != 0;
- }
-
- public void setLossless( boolean aLossless ) {
- setLossless(fPointer, aLossless ? 1 : 0);
- }
-
- public int getTargetSize() {
- return getTargetSize( fPointer );
- }
-
- public void setTargetSize( int aTargetSize ) {
- setTargetSize( fPointer, aTargetSize );
- }
-
- public float getTargetPSNR() {
- return getTargetPSNR( fPointer );
- }
-
- public void setTargetPSNR( float aTargetPSNR ) {
- setTargetPSNR( fPointer, aTargetPSNR );
- }
-
- public int getMethod() {
- return getMethod( fPointer );
- }
-
- public void setMethod( int aMethod ) {
- setMethod( fPointer, aMethod );
- }
-
- public int getSegments() {
- return getSegments( fPointer );
- }
-
- public void setSegments( int aSegments ) {
- setSegments( fPointer, aSegments );
- }
-
- public int getSnsStrength() {
- return getSnsStrength( fPointer );
- }
-
- public void setSnsStrength( int aSnsStrength ) {
- setSnsStrength( fPointer, aSnsStrength );
- }
-
- public int getFilterStrength() {
- return getFilterStrength( fPointer );
- }
-
- public void setFilterStrength( int aFilterStrength ) {
- setFilterStrength( fPointer, aFilterStrength );
- }
-
- public int getFilterSharpness() {
- return getFilterSharpness( fPointer );
- }
-
- public void setFilterSharpness( int aFilterSharpness ) {
- setFilterSharpness( fPointer, aFilterSharpness );
- }
-
- public int getFilterType() {
- return getFilterType( fPointer );
- }
-
- public void setFilterType( int aFilterType ) {
- setFilterType( fPointer, aFilterType );
- }
-
- public boolean isAutoAdjustFilterStrength() {
- return getAutofilter( fPointer ) != 0;
- }
-
- public void setAutoAdjustFilterStrength( boolean aAutofilter ) {
- setAutofilter( fPointer, aAutofilter ? 1 : 0 );
- }
-
- public int getEntropyAnalysisPassCount() {
- return getPass( fPointer );
- }
-
- public void setEntropyAnalysisPassCount( int aPass ) {
- setPass( fPointer, aPass );
- }
-
- public boolean isShowCompressed() {
- return getShowCompressed( fPointer ) != 0;
- }
-
- public void setShowCompressed( boolean aShowCompressed ) {
- setShowCompressed( fPointer, aShowCompressed ? 1 : 0 );
- }
-
- public int getPreprocessing() {
- return getPreprocessing( fPointer );
- }
-
- public void setPreprocessing( int aPreprocessing ) {
- setPreprocessing( fPointer, aPreprocessing );
- }
-
- public int getPartitions() {
- return getPartitions( fPointer );
- }
-
- public void setPartitions( int aPartitions ) {
- setPartitions( fPointer, aPartitions );
- }
-
- public int getPartitionLimit() {
- return getPartitionLimit( fPointer );
- }
-
- public void setPartitionLimit( int aPartitionLimit ) {
- setPartitionLimit( fPointer, aPartitionLimit );
- }
-
- public int getAlphaCompression() {
- return getAlphaCompression( fPointer );
- }
-
- public void setAlphaCompression( int aAlphaCompression ) {
- setAlphaCompression( fPointer, aAlphaCompression );
- }
-
- public int getAlphaFiltering() {
- return getAlphaFiltering( fPointer );
- }
-
- public void setAlphaFiltering( int aAlphaFiltering ) {
- setAlphaFiltering( fPointer, aAlphaFiltering );
- }
-
- public int getAlphaQuality() {
- return getAlphaQuality( fPointer );
- }
-
- public void setAlphaQuality( int aAlphaQuality ) {
- setAlphaQuality( fPointer, aAlphaQuality );
- }
-
- public boolean isEmulateJpegSize() {
- return getEmulateJpegSize( fPointer ) != 0;
- }
-
- public void setEmulateJpegSize( boolean aEmulateJpegSize ) {
- setEmulateJpegSize( fPointer, aEmulateJpegSize ? 1 : 0 );
- }
-
- public int getThreadLevel() {
- return getThreadLevel( fPointer );
- }
-
- public void setThreadLevel( int aThreadLevel ) {
- setThreadLevel( fPointer, aThreadLevel );
- }
-
- public boolean isReduceMemoryUsage() {
- return getLowMemory( fPointer ) != 0;
- }
-
- public void setReduceMemoryUsage( boolean aLowMemory ) {
- setLowMemory( fPointer, aLowMemory ? 1 : 0 );
- }
-
- private static native float getQuality( long aPointer );
-
- private static native void setQuality( long aPointer, float aQuality );
-
- private static native int getTargetSize( long aPointer );
-
- private static native void setTargetSize( long aPointer, int aTargetSize );
-
- private static native float getTargetPSNR( long aPointer );
-
- private static native void setTargetPSNR( long aPointer, float aTargetPSNR );
-
- private static native int getMethod( long aPointer );
-
- private static native void setMethod( long aPointer, int aMethod );
-
- private static native int getSegments( long aPointer );
-
- private static native void setSegments( long aPointer, int aSegments );
-
- private static native int getSnsStrength( long aPointer );
-
- private static native void setSnsStrength( long aPointer, int aSnsStrength );
-
- private static native int getFilterStrength( long aPointer );
-
- private static native void setFilterStrength( long aPointer, int aFilterStrength );
-
- private static native int getFilterSharpness( long aPointer );
-
- private static native void setFilterSharpness( long aPointer, int aFilterSharpness );
-
- private static native int getFilterType( long aPointer );
-
- private static native void setFilterType( long aPointer, int aFilterType );
-
- private static native int getAutofilter( long aPointer );
-
- private static native void setAutofilter( long aPointer, int aAutofilter );
-
- private static native int getPass( long aPointer );
-
- private static native void setPass( long aPointer, int aPass );
-
- private static native int getShowCompressed( long aPointer );
-
- private static native void setShowCompressed( long aPointer, int aShowCompressed );
-
- private static native int getPreprocessing( long aPointer );
-
- private static native void setPreprocessing( long aPointer, int aPreprocessing );
-
- private static native int getPartitions( long aPointer );
-
- private static native void setPartitions( long aPointer, int aPartitions );
-
- private static native int getPartitionLimit( long aPointer );
-
- private static native void setPartitionLimit( long aPointer, int aPartitionLimit );
-
- private static native int getAlphaCompression( long aPointer );
-
- private static native void setAlphaCompression( long aPointer, int aAlphaCompression );
-
- private static native int getAlphaFiltering( long aPointer );
-
- private static native void setAlphaFiltering( long aPointer, int aAlphaFiltering );
-
- private static native int getAlphaQuality( long aPointer );
-
- private static native void setAlphaQuality( long aPointer, int aAlphaQuality );
-
- private static native int getLossless( long aPointer );
-
- private static native void setLossless( long aPointer, int aLossless );
-
- private static native int getEmulateJpegSize( long aPointer );
-
- private static native void setEmulateJpegSize( long aPointer, int aEmulateJpegSize );
-
- private static native int getThreadLevel( long aPointer );
-
- private static native void setThreadLevel( long aPointer, int aThreadLevel );
-
- private static native int getLowMemory( long aPointer );
-
- private static native void setLowMemory( long aPointer, int aLowMemory );
-}
diff --git a/src/main/java/com/luciad/imageio/webp/WebPImageReaderSpi.java b/src/main/java/com/luciad/imageio/webp/WebPImageReaderSpi.java
deleted file mode 100644
index bf4a37b..0000000
--- a/src/main/java/com/luciad/imageio/webp/WebPImageReaderSpi.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 2013 Luciad (http://www.luciad.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.luciad.imageio.webp;
-
-import javax.imageio.ImageReader;
-import javax.imageio.spi.ImageReaderSpi;
-import javax.imageio.stream.ImageInputStream;
-import java.io.IOException;
-import java.nio.ByteOrder;
-import java.util.Arrays;
-import java.util.Locale;
-
-/**
- *
- */
-public class WebPImageReaderSpi extends ImageReaderSpi {
- private static final byte[] RIFF = new byte[]{ 'R', 'I', 'F', 'F' };
- private static final byte[] WEBP = new byte[]{ 'W', 'E', 'B', 'P' };
- private static final byte[] VP8_ = new byte[]{ 'V', 'P', '8', ' ' };
- private static final byte[] VP8L = new byte[]{ 'V', 'P', '8', 'L' };
- private static final byte[] VP8X = new byte[]{ 'V', 'P', '8', 'X' };
-
- public WebPImageReaderSpi() {
- super(
- "Luciad",
- "1.0",
- new String[]{ "WebP", "webp" },
- new String[]{ "webp" },
- new String[]{ "image/webp" },
- WebPReader.class.getName(),
- new Class[] { ImageInputStream.class },
- new String[]{ WebPImageWriterSpi.class.getName() },
- false,
- null,
- null,
- null,
- null,
- false,
- null,
- null,
- null,
- null
- );
- }
-
- @Override
- public ImageReader createReaderInstance( Object extension ) throws IOException {
- return new WebPReader( this );
- }
-
- @Override
- public boolean canDecodeInput( Object source ) throws IOException {
- if ( !( source instanceof ImageInputStream ) ) {
- return false;
- }
-
- ImageInputStream stream = ( ImageInputStream ) source;
- byte[] b = new byte[ 4 ];
- ByteOrder oldByteOrder = stream.getByteOrder();
- stream.mark();
- stream.setByteOrder( ByteOrder.LITTLE_ENDIAN );
-
- try {
- stream.readFully( b );
- if ( !Arrays.equals( b, RIFF ) ) {
- return false;
- }
- long chunkLength = stream.readUnsignedInt();
- long streamLength = stream.length();
- if ( streamLength != -1 && streamLength != chunkLength + 8 ) {
- return false;
- }
- stream.readFully( b );
- if ( !Arrays.equals( b, WEBP ) ) {
- return false;
- }
-
- stream.readFully( b );
- if ( !Arrays.equals( b, VP8_ ) && !Arrays.equals( b, VP8L ) && !Arrays.equals( b, VP8X ) ) {
- return false;
- }
- } finally {
- stream.setByteOrder( oldByteOrder );
- stream.reset();
- }
-
- return true;
- }
-
- @Override
- public String getDescription( Locale locale ) {
- return "WebP Reader";
- }
-}
diff --git a/src/main/java/com/luciad/imageio/webp/WebPImageWriterSpi.java b/src/main/java/com/luciad/imageio/webp/WebPImageWriterSpi.java
deleted file mode 100644
index 78e92f4..0000000
--- a/src/main/java/com/luciad/imageio/webp/WebPImageWriterSpi.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2013 Luciad (http://www.luciad.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.luciad.imageio.webp;
-
-import javax.imageio.ImageTypeSpecifier;
-import javax.imageio.ImageWriter;
-import javax.imageio.spi.ImageWriterSpi;
-import javax.imageio.stream.ImageOutputStream;
-import java.awt.color.ColorSpace;
-import java.awt.image.ColorModel;
-import java.awt.image.ComponentColorModel;
-import java.awt.image.ComponentSampleModel;
-import java.awt.image.DataBuffer;
-import java.awt.image.DirectColorModel;
-import java.awt.image.SampleModel;
-import java.awt.image.SinglePixelPackedSampleModel;
-import java.io.IOException;
-import java.util.Locale;
-
-/**
- *
- */
-public class WebPImageWriterSpi extends ImageWriterSpi {
- public WebPImageWriterSpi() {
- super(
- "Luciad",
- "1.0",
- new String[]{ "WebP", "webp" },
- new String[]{ "webp" },
- new String[]{ "image/webp" },
- WebPReader.class.getName(),
- new Class[]{ ImageOutputStream.class },
- new String[]{ WebPImageReaderSpi.class.getName() },
- false,
- null,
- null,
- null,
- null,
- false,
- null,
- null,
- null,
- null
- );
- }
-
- @Override
- public boolean canEncodeImage( ImageTypeSpecifier type ) {
- ColorModel colorModel = type.getColorModel();
- SampleModel sampleModel = type.getSampleModel();
- int transferType = sampleModel.getTransferType();
-
- if ( colorModel instanceof ComponentColorModel ) {
- if ( !( sampleModel instanceof ComponentSampleModel ) ) {
- return false;
- }
-
- if ( transferType != DataBuffer.TYPE_BYTE && transferType != DataBuffer.TYPE_INT ) {
- return false;
- }
- }
- else if ( colorModel instanceof DirectColorModel ) {
- if ( !( sampleModel instanceof SinglePixelPackedSampleModel ) ) {
- return false;
- }
-
- if ( transferType != DataBuffer.TYPE_INT ) {
- return false;
- }
- }
-
- ColorSpace colorSpace = colorModel.getColorSpace();
- if ( !( colorSpace.isCS_sRGB() ) ) {
- return false;
- }
-
- int[] sampleSize = sampleModel.getSampleSize();
- for ( int i = 0; i < sampleSize.length; i++ ) {
- if ( sampleSize[ i ] > 8 ) {
- return false;
- }
- }
-
-
- return true;
- }
-
- @Override
- public ImageWriter createWriterInstance( Object extension ) throws IOException {
- return new WebPWriter( this );
- }
-
- @Override
- public String getDescription( Locale locale ) {
- return "WebP Writer";
- }
-}
diff --git a/src/main/java/com/luciad/imageio/webp/WebPReadParam.java b/src/main/java/com/luciad/imageio/webp/WebPReadParam.java
deleted file mode 100644
index 52bf241..0000000
--- a/src/main/java/com/luciad/imageio/webp/WebPReadParam.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2013 Luciad (http://www.luciad.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.luciad.imageio.webp;
-
-import javax.imageio.ImageReadParam;
-
-public final class WebPReadParam extends ImageReadParam {
- private WebPDecoderOptions fOptions;
-
- public WebPReadParam() {
- fOptions = new WebPDecoderOptions();
- }
-
- public void setScaledHeight(int aScaledHeight) {
- fOptions.setScaledHeight(aScaledHeight);
- }
-
- public void setUseScaling(boolean aUseScaling) {
- fOptions.setUseScaling(aUseScaling);
- }
-
- public void setUseThreads(boolean aUseThreads) {
- fOptions.setUseThreads(aUseThreads);
- }
-
- public int getCropHeight() {
- return fOptions.getCropHeight();
- }
-
- public int getScaledWidth() {
- return fOptions.getScaledWidth();
- }
-
- public boolean isUseCropping() {
- return fOptions.isUseCropping();
- }
-
- public void setCropWidth(int aCropWidth) {
- fOptions.setCropWidth(aCropWidth);
- }
-
- public boolean isBypassFiltering() {
- return fOptions.isBypassFiltering();
- }
-
- public int getCropLeft() {
- return fOptions.getCropLeft();
- }
-
- public int getCropWidth() {
- return fOptions.getCropWidth();
- }
-
- public int getScaledHeight() {
- return fOptions.getScaledHeight();
- }
-
- public void setBypassFiltering(boolean aBypassFiltering) {
- fOptions.setBypassFiltering(aBypassFiltering);
- }
-
- public void setUseCropping(boolean aUseCropping) {
- fOptions.setUseCropping(aUseCropping);
- }
-
- public void setCropHeight(int aCropHeight) {
- fOptions.setCropHeight(aCropHeight);
- }
-
- public void setFancyUpsampling(boolean aFancyUpsampling) {
- fOptions.setFancyUpsampling(aFancyUpsampling);
- }
-
- public boolean isUseThreads() {
- return fOptions.isUseThreads();
- }
-
- public boolean isFancyUpsampling() {
- return fOptions.isFancyUpsampling();
- }
-
- public boolean isUseScaling() {
- return fOptions.isUseScaling();
- }
-
- public void setCropLeft(int aCropLeft) {
- fOptions.setCropLeft(aCropLeft);
- }
-
- public int getCropTop() {
- return fOptions.getCropTop();
- }
-
- public void setScaledWidth(int aScaledWidth) {
- fOptions.setScaledWidth(aScaledWidth);
- }
-
- public void setCropTop(int aCropTop) {
- fOptions.setCropTop(aCropTop);
- }
-
- WebPDecoderOptions getDecoderOptions() {
- return fOptions;
- }
-}
diff --git a/src/main/java/com/luciad/imageio/webp/WebPReader.java b/src/main/java/com/luciad/imageio/webp/WebPReader.java
deleted file mode 100644
index ed3809d..0000000
--- a/src/main/java/com/luciad/imageio/webp/WebPReader.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright 2013 Luciad (http://www.luciad.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.luciad.imageio.webp;
-
-import javax.imageio.ImageReadParam;
-import javax.imageio.ImageReader;
-import javax.imageio.ImageTypeSpecifier;
-import javax.imageio.metadata.IIOMetadata;
-import javax.imageio.spi.ImageReaderSpi;
-import javax.imageio.stream.ImageInputStream;
-import java.awt.image.BufferedImage;
-import java.awt.image.ColorModel;
-import java.awt.image.DataBufferInt;
-import java.awt.image.DirectColorModel;
-import java.awt.image.SampleModel;
-import java.awt.image.WritableRaster;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.nio.ByteOrder;
-import java.util.Collections;
-import java.util.Hashtable;
-import java.util.Iterator;
-
-class WebPReader extends ImageReader {
- private byte[] fData;
- private int fWidth;
- private int fHeight;
-
- WebPReader( ImageReaderSpi originatingProvider ) {
- super( originatingProvider );
- }
-
- @Override
- public void setInput( Object input, boolean seekForwardOnly, boolean ignoreMetadata ) {
- super.setInput( input, seekForwardOnly, ignoreMetadata );
- fData = null;
- fWidth = -1;
- fHeight = -1;
- }
-
- @Override
- public int getNumImages( boolean allowSearch ) throws IOException {
- return 1;
- }
-
- private void readHeader() throws IOException {
- if ( fWidth != -1 && fHeight != -1 ) {
- return;
- }
-
- readData();
- int[] info = WebP.getInfo( fData, 0, fData.length );
- fWidth = info[ 0 ];
- fHeight = info[ 1 ];
- }
-
- private void readData() throws IOException {
- if ( fData != null ) {
- return;
- }
-
- ImageInputStream input = ( ImageInputStream ) getInput();
- long length = input.length();
- if ( length > Integer.MAX_VALUE ) {
- throw new IOException( "Cannot read image of size " + length );
- }
-
- if ( input.getStreamPosition() != 0L ) {
- if ( isSeekForwardOnly() ) {
- throw new IOException();
- }
- else {
- input.seek( 0 );
- }
- }
-
- byte[] data;
- if ( length > 0 ) {
- data = new byte[ ( int ) length ];
- input.readFully( data );
- }
- else {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- byte[] buffer = new byte[ 4096 ];
- int bytesRead;
- while ( ( bytesRead = input.read( buffer ) ) != -1 ) {
- out.write( buffer, 0, bytesRead );
- }
- out.close();
- data = out.toByteArray();
- }
- fData = data;
- }
-
- private void checkIndex( int imageIndex ) {
- if ( imageIndex != 0 ) {
- throw new IndexOutOfBoundsException( "Invalid image index: " + imageIndex );
- }
- }
-
- @Override
- public int getWidth( int imageIndex ) throws IOException {
- checkIndex( imageIndex );
- readHeader();
- return fWidth;
- }
-
- @Override
- public int getHeight( int imageIndex ) throws IOException {
- checkIndex( imageIndex );
- readHeader();
- return fHeight;
- }
-
- @Override
- public IIOMetadata getStreamMetadata() throws IOException {
- return null;
- }
-
- @Override
- public IIOMetadata getImageMetadata( int imageIndex ) throws IOException {
- return null;
- }
-
- @Override
- public Iterator getImageTypes( int imageIndex ) throws IOException {
- return Collections.singletonList(
- ImageTypeSpecifier.createFromBufferedImageType( BufferedImage.TYPE_INT_ARGB )
- ).iterator();
- }
-
- @Override
- public ImageReadParam getDefaultReadParam() {
- return new WebPReadParam();
- }
-
- @Override
- public BufferedImage read( int imageIndex, ImageReadParam param ) throws IOException {
- checkIndex( imageIndex );
- readData();
- readHeader();
- WebPReadParam readParam = param != null ? (WebPReadParam) param : new WebPReadParam();
-
- int[] outParams = new int[4];
- int[] pixels = WebP.decode(readParam.getDecoderOptions(), fData, 0, fData.length, outParams);
-
- int width = outParams[1];
- int height = outParams[2];
- boolean alpha = outParams[3] != 0;
-
- ColorModel colorModel;
- if ( alpha ) {
- colorModel = new DirectColorModel( 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 );
- } else {
- colorModel = new DirectColorModel( 24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000 );
- }
-
- SampleModel sampleModel = colorModel.createCompatibleSampleModel( width, height );
- DataBufferInt db = new DataBufferInt( pixels, width * height );
- WritableRaster raster = WritableRaster.createWritableRaster(sampleModel, db, null);
-
- return new BufferedImage( colorModel, raster, false, new Hashtable