diff --git a/ucrop/src/main/java/com/yalantis/ucrop/view/CropImageView.java b/ucrop/src/main/java/com/yalantis/ucrop/view/CropImageView.java index 9fdb1406b..921bfa45d 100644 --- a/ucrop/src/main/java/com/yalantis/ucrop/view/CropImageView.java +++ b/ucrop/src/main/java/com/yalantis/ucrop/view/CropImageView.java @@ -297,8 +297,6 @@ public void setImageToWrapCropBounds(boolean animate) { deltaScale = Math.max(tempCropRect.width() / currentImageSides[0], tempCropRect.height() / currentImageSides[1]); - // Ugly but there are always couple pixels that want to hide because of all these calculations - deltaScale *= 1.01; deltaScale = deltaScale * currentScale - currentScale; } diff --git a/ucrop/src/main/jni/uCrop.cpp b/ucrop/src/main/jni/uCrop.cpp index a551202ea..d4c90a463 100644 --- a/ucrop/src/main/jni/uCrop.cpp +++ b/ucrop/src/main/jni/uCrop.cpp @@ -53,31 +53,37 @@ JNIEXPORT jboolean JNICALL Java_com_yalantis_ucrop_task_BitmapCropTask_cropCImg img.resize(size_x, size_y, size_z, size_c, interpolation_type, boundary_conditions, centering_x, centering_y, centering_z, centering_c); } - // Create warp field. - CImg warp(cimg::abs(x1 - x0 + 1), cimg::abs(y1 - y0 + 1), 1, 2); - const float - rad = angle * cimg::PI/180, - ca = std::cos(rad), sa = std::sin(rad), - ux = cimg::abs(img.width() * ca), uy = cimg::abs(img.width() * sa), - vx = cimg::abs(img.height() * sa), vy = cimg::abs(img.height() * ca), - w2 = 0.5f * img.width(), h2 = 0.5f * img.height(), - dw2 = 0.5f * (ux + vx), dh2 = 0.5f * (uy + vy); - - cimg_forXY(warp, x, y) { - const float - u = x + x0 - dw2, v = y + y0 - dh2; + if (!(img.width() == width && img.height() == height && angle == 0)) { - warp(x, y, 0) = w2 + u*ca + v*sa; - warp(x, y, 1) = h2 - u*sa + v*ca; + // Create warp field. + CImg warp(cimg::abs(x1 - x0 + 1), cimg::abs(y1 - y0 + 1), 1, 2); + + const float + rad = angle * cimg::PI/180, + ca = std::cos(rad), sa = std::sin(rad), + ux = cimg::abs(img.width() * ca), uy = cimg::abs(img.width() * sa), + vx = cimg::abs(img.height() * sa), vy = cimg::abs(img.height() * ca), + w2 = 0.5f * img.width(), h2 = 0.5f * img.height(), + dw2 = 0.5f * (ux + vx), dh2 = 0.5f * (uy + vy); + + cimg_forXY(warp, x, y) { + const float + u = x + x0 - dw2, v = y + y0 - dh2; + + warp(x, y, 0) = w2 + u*ca + v*sa; + warp(x, y, 1) = h2 - u*sa + v*ca; + } + + img = img.get_warp(warp, 0, 1, 2); } if (format == SAVE_FORMAT_JPEG) { - img.get_warp(warp, 0, 1, 2).save_jpeg(file_result_path, quality); + img.save_jpeg(file_result_path, quality); } else if (format == SAVE_FORMAT_PNG) { - img.get_warp(warp, 0, 1, 2).save_png(file_result_path, 0); + img.save_png(file_result_path, 0); } else { - img.get_warp(warp, 0, 1, 2).save(file_result_path); + img.save(file_result_path); } ~img; diff --git a/ucrop/src/main/jniLibs/arm64-v8a/libucrop.so b/ucrop/src/main/jniLibs/arm64-v8a/libucrop.so index 0d4095aab..c870785ab 100755 Binary files a/ucrop/src/main/jniLibs/arm64-v8a/libucrop.so and b/ucrop/src/main/jniLibs/arm64-v8a/libucrop.so differ diff --git a/ucrop/src/main/jniLibs/armeabi-v7a/libucrop.so b/ucrop/src/main/jniLibs/armeabi-v7a/libucrop.so index 64d8f1476..bd3ed45df 100755 Binary files a/ucrop/src/main/jniLibs/armeabi-v7a/libucrop.so and b/ucrop/src/main/jniLibs/armeabi-v7a/libucrop.so differ diff --git a/ucrop/src/main/jniLibs/armeabi/libucrop.so b/ucrop/src/main/jniLibs/armeabi/libucrop.so index 32fabb3d3..766771143 100755 Binary files a/ucrop/src/main/jniLibs/armeabi/libucrop.so and b/ucrop/src/main/jniLibs/armeabi/libucrop.so differ diff --git a/ucrop/src/main/jniLibs/mips/libucrop.so b/ucrop/src/main/jniLibs/mips/libucrop.so index a412c1356..d6f95a414 100755 Binary files a/ucrop/src/main/jniLibs/mips/libucrop.so and b/ucrop/src/main/jniLibs/mips/libucrop.so differ diff --git a/ucrop/src/main/jniLibs/mips64/libucrop.so b/ucrop/src/main/jniLibs/mips64/libucrop.so index 60db6d8a5..62e67c4e2 100755 Binary files a/ucrop/src/main/jniLibs/mips64/libucrop.so and b/ucrop/src/main/jniLibs/mips64/libucrop.so differ diff --git a/ucrop/src/main/jniLibs/x86/libucrop.so b/ucrop/src/main/jniLibs/x86/libucrop.so index 492499617..19c27d8fa 100755 Binary files a/ucrop/src/main/jniLibs/x86/libucrop.so and b/ucrop/src/main/jniLibs/x86/libucrop.so differ diff --git a/ucrop/src/main/jniLibs/x86_64/libucrop.so b/ucrop/src/main/jniLibs/x86_64/libucrop.so index 38bcf6b62..df66349eb 100755 Binary files a/ucrop/src/main/jniLibs/x86_64/libucrop.so and b/ucrop/src/main/jniLibs/x86_64/libucrop.so differ