From d08598ab71f5ccde5bdd96ccbd74a5911c536951 Mon Sep 17 00:00:00 2001 From: seven332 Date: Tue, 26 Aug 2014 09:59:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=94=B1=E4=BA=8E=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E5=AE=BD=E5=BA=A6=E8=80=8C=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E9=94=99=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jni/gif.c | 8 +++++++- jni/utils.c | 4 ++++ jni/utils.h | 2 ++ src/com/hippo/ehviewer/util/Utils.java | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/jni/gif.c b/jni/gif.c index aa63661a6..7106d0f97 100644 --- a/jni/gif.c +++ b/jni/gif.c @@ -436,6 +436,7 @@ jobject GIF_DecodeStream(JNIEnv* env, jobject is, jint format) { GIF* gif; int slurp, imageCount; int* delays; + int realWidth; // GIF not sc = getStreamContainer(env, is); @@ -449,6 +450,11 @@ jobject GIF_DecodeStream(JNIEnv* env, jobject is, jint format) { return NULL; } + // Fix width, for not RGBA, but I will tell others the real width + realWidth = gifFile->SWidth; + if (format != GL_RGBA) + gifFile->SWidth = nextMulOf4(realWidth); + // Slurp slurp = DGifSlurp(gifFile); // Free container @@ -489,7 +495,7 @@ jobject GIF_DecodeStream(JNIEnv* env, jobject is, jint format) { return NULL; else return (*env)->NewObject(env, gifClazz, constructor, (jint) gif, - FORMAT_GIF, gifFile->SWidth, gifFile->SHeight, format, + FORMAT_GIF, realWidth, gifFile->SHeight, format, DEFAULT_TYPE, delayArray); } diff --git a/jni/utils.c b/jni/utils.c index 17839be16..588423644 100644 --- a/jni/utils.c +++ b/jni/utils.c @@ -1,6 +1,10 @@ #include "image.h" #include "utils.h" +int nextMulOf4(int x) { + return (x + 3) / 4 * 4; +} + byte getVFrowRGB(byte r, byte g, byte b) { byte t = g > b ? g : b; return r > t ? r : t; diff --git a/jni/utils.h b/jni/utils.h index 473c9cd3d..37a0c6340 100644 --- a/jni/utils.h +++ b/jni/utils.h @@ -11,6 +11,8 @@ typedef struct { jbyteArray buffer; } StreamContainer; +int nextMulOf4(int x); + void eraseRGB(rgb* pixels, int num, rgb color); void eraseRGBA(rgba* pixels, int num, rgba color); void eraseLUM(lum* pixels, int num, lum color); diff --git a/src/com/hippo/ehviewer/util/Utils.java b/src/com/hippo/ehviewer/util/Utils.java index 3f670405b..46e02bcf4 100644 --- a/src/com/hippo/ehviewer/util/Utils.java +++ b/src/com/hippo/ehviewer/util/Utils.java @@ -174,6 +174,7 @@ public final class Utils { }.start(); } + // TODO @SuppressLint("SimpleDateFormat") public static int getDate() { int time = 0;