diff --git a/app/src/main/java/xdsopl/robot36/MainActivity.java b/app/src/main/java/xdsopl/robot36/MainActivity.java index 7ee7131..0d05ac3 100644 --- a/app/src/main/java/xdsopl/robot36/MainActivity.java +++ b/app/src/main/java/xdsopl/robot36/MainActivity.java @@ -17,6 +17,7 @@ import android.content.res.Configuration; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; +import android.graphics.Rect; import android.media.AudioFormat; import android.media.AudioRecord; import android.media.MediaRecorder; @@ -845,22 +846,29 @@ public class MainActivity extends AppCompatActivity { int stride = scopeBuffer.width; int offset = stride * scopeBuffer.line; Bitmap bmp = Bitmap.createBitmap(scopeBuffer.pixels, offset, stride, width, height, Bitmap.Config.ARGB_8888); - if (currentMode == null || !currentMode.equals("HF Fax")) { - bmp = Bitmap.createScaledBitmap(bmp, width / 3, height / 3, true); - } else { + if (decoder != null && decoder.currentMode.getName().equals("HF Fax")) { Mode mode = decoder.currentMode; int shift = mode.getEstimatedHorizontalShift(); if (shift > 0) { - Bitmap part1 = Bitmap.createBitmap(bmp, 0, 0, shift, bmp.getHeight()); - Bitmap part2 = Bitmap.createBitmap(bmp, shift, 0, mode.getWidth() - shift, bmp.getHeight()); - Bitmap bmpMutable = Bitmap.createBitmap(mode.getWidth(), bmp.getHeight(), Bitmap.Config.ARGB_8888); - Canvas canvas = new android.graphics.Canvas(bmpMutable); - canvas.drawBitmap(part2, 0, 1, null); - canvas.drawBitmap(part1, mode.getWidth() - shift, 0, null); + Canvas canvas = new Canvas(bmpMutable); + canvas.drawBitmap( + bmp, + new Rect(0, 0, shift, bmp.getHeight()), + new Rect(mode.getWidth() - shift, 0, mode.getWidth(), bmp.getHeight()), + null); + canvas.drawBitmap( + bmp, + new Rect(shift, 0, mode.getWidth(), bmp.getHeight()), + new Rect(0, 1, mode.getWidth() - shift, bmp.getHeight() + 1), + null); + bmp = bmpMutable; } + } else { + bmp = Bitmap.createScaledBitmap(bmp, width / 3, height / 3, true); } + storeBitmap(bmp); }