cropiwa
cropiwa copied to clipboard
crop size more than screen width
Error occurs on https://www.gsmarena.com/oneplus_5t-8912.php cropiwa settings:
app:ci_aspect_ratio_h="4"
app:ci_aspect_ratio_w="3"
app:ci_border_color="@color/colorAccentGreen"
app:ci_border_width="4dp"
app:ci_crop_scale="0.75"
app:ci_crop_shape="rectangle"
app:ci_draw_grid="false"
app:ci_dynamic_aspect_ratio="false"
app:ci_scale_enabled="true"
app:ci_translation_enabled="true"
Problem in method CropiwaOverlayView>setCropRectAccordingToAspectRatio()
boolean calculateFromWidth =
aspectRatio.getHeight() < aspectRatio.getWidth()
|| (aspectRatio.isSquare() && viewWidth < viewHeight);
if (calculateFromWidth) {
halfWidth = viewWidth * cropScale * 0.5f;
halfHeight = halfWidth / aspectRatio.getRatio();
} else {
halfHeight = viewHeight * cropScale * 0.5f;
halfWidth = halfHeight * aspectRatio.getRatio();
}
cropRect.set(
centerX - halfWidth, centerY - halfHeight,
centerX + halfWidth, centerY + halfHeight);
calculate as 2160×0.75×3/4 = 1215. This is more than 1080 width this phone (screen ratio 18:9)