reduced max height so we can enjoy more of the maximally scaled picture

This commit is contained in:
Ahmet Inan 2014-12-12 10:47:13 +01:00
parent 8828cbc753
commit 0d5407f090

View file

@ -105,7 +105,7 @@ public class ImageView extends SurfaceView implements SurfaceHolder.Callback {
holder.addCallback(this);
paint = new Paint(Paint.FILTER_BITMAP_FLAG);
bitmap = Bitmap.createBitmap(320, 512, Bitmap.Config.ARGB_8888);
bitmap = Bitmap.createBitmap(320, 384, Bitmap.Config.ARGB_8888);
pixelBuffer = new int[bitmap.getWidth() * bitmap.getHeight()];
int bufferSizeInBytes = AudioRecord.getMinBufferSize(sampleRate, channelConfig, audioFormat);
@ -212,7 +212,7 @@ public class ImageView extends SurfaceView implements SurfaceHolder.Callback {
synchronized (thread) {
switch (mode) {
case mode_debug:
imageWidth = 320;
imageWidth = bitmap.getWidth();
imageHeight = bitmap.getHeight();
updateTitle(R.string.action_debug_mode);
break;
@ -302,13 +302,13 @@ public class ImageView extends SurfaceView implements SurfaceHolder.Callback {
void drawBitmap(Canvas canvas) {
float sx, sy, px, py;
if (imageWidth * canvasHeight < canvasWidth * bitmap.getHeight()) {
sx = (float)canvasHeight * imageWidth / (bitmap.getWidth() * bitmap.getHeight());
sy = (float)canvasHeight / bitmap.getHeight();
sx = sy * imageWidth / bitmap.getWidth();
px = (canvasWidth - sx * bitmap.getWidth()) / 2.0f;
py = 0.0f;
} else {
sx = (float)canvasWidth / bitmap.getWidth();
sy = (float)canvasWidth * imageHeight / (bitmap.getHeight() * imageWidth);
sy = sx;
px = 0.0f;
py = (canvasHeight - sy * bitmap.getHeight()) / 2.0f;
}