diff --git a/.gitignore b/.gitignore
index 32858aa..0460bc2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,12 +1,36 @@
-*.class
-
-# Mobile Tools for Java (J2ME)
-.mtj.tmp/
-
-# Package Files #
-*.jar
+# maven ignore
+target/
*.war
-*.ear
+*.zip
+*.tar
+*.tar.gz
-# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
-hs_err_pid*
+# eclipse ignore
+.settings/
+.project
+.classpath
+.tern-project
+
+# idea ignore
+.idea/
+*.ipr
+*.iml
+*.iws
+
+# temp ignore
+.svn/
+generated/
+.externalToolBuilders/
+logs/
+*.log
+*.cache
+*.diff
+*.patch
+*.tmp
+*.java~
+*.properties~
+*.xml~
+
+# system ignore
+.DS_Store
+Thumbs.db
\ No newline at end of file
diff --git a/README.md b/README.md
index 315e50b..e652840 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,11 @@
# j-webp
Java Image I/O reader and writer for the Google WebP image format.
+
+基于[webp project of Luciad](https://bitbucket.org/luciad/webp-imageio) 0.4.2版本修改.
+
+实际上只修改了`com.luciad.imageio.webp.WebP.loadNativeLibrary`这一个方法.
+因为按他默认的加载方式, 需要把native的so/dll/dylib等文件放到OS对应的`java.library.path`对应的目录才能加载到, 这会给部署带来一些不便.
+
+所以我们这里换成了[native-lib-loader](https://github.com/scijava/native-lib-loader)自动加载, 编译构建好的包里已经包含了各种OS上的native文件, 使用时会自动加载.
+
+具体使用方法可参看`src/main/java/example`下的源码.
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..dcbafff
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,25 @@
+
+
+ 4.0.0
+
+ net.wangq
+ webp
+ 1.0-SNAPSHOT
+
+
+ UTF-8
+ 1.7
+ 1.7
+
+
+
+
+ org.scijava
+ native-lib-loader
+ 2.1.3
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/luciad/imageio/webp/VP8StatusCode.java b/src/main/java/com/luciad/imageio/webp/VP8StatusCode.java
new file mode 100644
index 0000000..0d1047e
--- /dev/null
+++ b/src/main/java/com/luciad/imageio/webp/VP8StatusCode.java
@@ -0,0 +1,38 @@
+/*
+ * 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
new file mode 100644
index 0000000..cdda853
--- /dev/null
+++ b/src/main/java/com/luciad/imageio/webp/WebP.java
@@ -0,0 +1,428 @@
+/*
+ * 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 org.scijava.nativelib.NativeLibraryUtil;
+
+import java.awt.image.*;
+import java.io.IOException;
+import java.nio.ByteOrder;
+import java.util.Hashtable;
+
+final class WebP {
+ private static boolean NATIVE_LIBRARY_LOADED = false;
+
+ static synchronized void loadNativeLibrary() {
+ if ( !NATIVE_LIBRARY_LOADED ) {
+ NATIVE_LIBRARY_LOADED = true;
+ NativeLibraryUtil.loadNativeLibrary(WebP.class, "webp-imageio");
+ }
+ }
+
+ static {
+ loadNativeLibrary();
+ }
+
+ private WebP() {
+ }
+
+ public static BufferedImage decode( WebPReadParam aReadParam, byte[] aData, int aOffset, int aLength ) throws IOException {
+ if ( aReadParam == 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[] out = new int[4];
+ int[] pixels = decode( aReadParam.fPointer, aData, aOffset, aLength, out, ByteOrder.nativeOrder().equals( ByteOrder.BIG_ENDIAN ) );
+ VP8StatusCode status = VP8StatusCode.getStatusCode( out[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 );
+ }
+
+ int width = out[1];
+ int height = out[2];
+ boolean alpha = out[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