From 9d3b1f755bad063a0b7ca2ed6b1f3373817eb718 Mon Sep 17 00:00:00 2001 From: master-lzh <60057825+master-lzh@users.noreply.github.com> Date: Sun, 29 Nov 2020 15:59:04 +0800 Subject: [PATCH 1/2] Update MH50.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新getImageUrlByKey函数 --- .../main/java/com/hiroshi/cimoc/source/MH50.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/hiroshi/cimoc/source/MH50.java b/app/src/main/java/com/hiroshi/cimoc/source/MH50.java index 83d353dc..f428b84e 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/MH50.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/MH50.java @@ -145,9 +145,9 @@ private String decrypt(String code) { //根据文件名获取图片url,参考common.js中getChapterImage函数 private String getImageUrlByKey(String key, String domain, String chapter) { - if (key.startsWith("http://images.dmzj.com")) { + if (Pattern.matches("\\^https?://(images.dmzj.com|imgsmall.dmzj.com)/i", key)) { try { - return domain +"/showImage.php?url=" + key; + return domain + "/showImage.php?url=" + URLEncoder.encode(key, "utf-8"); } catch (Exception e) { return null; } @@ -159,9 +159,14 @@ private String getImageUrlByKey(String key, String domain, String chapter) { return null; } } - if (key.startsWith("http") || key.startsWith("ftp")) { - return key; + if (Pattern.matches("\\^https?://(manhua.qpic.cn|mhimg.eshanyao.com|dd.wstts.com)/i",key)){ + try { + return "https://manga.mipcdn.com/i/s"+URLEncoder.encode(key,"utf-8"); + } catch (Exception e) { + return null; + } } + if (key.startsWith("http") || key.startsWith("ftp")) return key; return domain + "/" + chapter + key; } From 5e270054cc4684c04440d25280d86d62890b22df Mon Sep 17 00:00:00 2001 From: Haleydu <924323178@qq.com> Date: Mon, 30 Nov 2020 10:09:09 +0800 Subject: [PATCH 2/2] Optimized image processing --- .../fresco/processor/MangaPostprocessor.java | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/hiroshi/cimoc/fresco/processor/MangaPostprocessor.java b/app/src/main/java/com/hiroshi/cimoc/fresco/processor/MangaPostprocessor.java index 335e8915..26663615 100644 --- a/app/src/main/java/com/hiroshi/cimoc/fresco/processor/MangaPostprocessor.java +++ b/app/src/main/java/com/hiroshi/cimoc/fresco/processor/MangaPostprocessor.java @@ -3,6 +3,8 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Rect; +import android.graphics.RectF; +import android.util.Log; import com.facebook.cache.common.CacheKey; import com.facebook.cache.common.SimpleCacheKey; @@ -263,25 +265,31 @@ public void decodeJMTTImage(Bitmap sourceBitmap, CloseableReference refe String url = mImage.getUrl(); int scramble_id = 220980; int chapterId = 0; - if (url.startsWith("file://Cimoc/download/72/")){ + if (url.contains("/Cimoc/download/72/")){ chapterId = Integer.parseInt(Objects.requireNonNull(StringUtils.match("/-photo-(\\d*)/", url, 1))); } if((url.contains("media/photos") && Integer.parseInt(url.substring(url.indexOf("photos/") + 7, url.lastIndexOf("/"))) > scramble_id) || chapterId > scramble_id) { Bitmap resultBitmap = reference.get(); - float rows = 10; - float chunkHeight = mHeight / rows; - Canvas canvas = new Canvas(resultBitmap); + int rows = 10; + int remainder = mHeight % rows; + //Canvas canvas = new Canvas(resultBitmap); for (int x = 0; x < 10; x++) { - // 要裁剪的区域 - Rect crop = new Rect(0, mHeight - (int) (chunkHeight * (x + 1)), mWidth, mHeight - (int) (chunkHeight * x)); - // 裁剪后应放置到新图片对象的区域 - Rect splic = new Rect(0, (int) chunkHeight * x, mWidth, (int) chunkHeight * (x + 1)); - canvas.drawBitmap(sourceBitmap, crop, splic, null); + int chunkHeight = (int)Math.floor(mHeight / rows); + int py = chunkHeight * (x); + int y = mHeight - chunkHeight * (x + 1) - remainder; + + if (x == 0) { + chunkHeight = chunkHeight + remainder; + } else { + py = py + remainder; + } + int[] pixels = new int[(chunkHeight) * mWidth]; + sourceBitmap.getPixels(pixels, 0, mWidth, 0, y, mWidth, chunkHeight); + resultBitmap.setPixels(pixels, 0, mWidth, 0, py, mWidth, chunkHeight); } jmttIsDone=true; } } - }