|
|
@ -15,6 +15,7 @@ import android.content.DialogInterface; |
|
|
|
import android.content.res.TypedArray; |
|
|
|
import android.content.res.TypedArray; |
|
|
|
import android.graphics.Bitmap; |
|
|
|
import android.graphics.Bitmap; |
|
|
|
import android.graphics.Canvas; |
|
|
|
import android.graphics.Canvas; |
|
|
|
|
|
|
|
import android.graphics.Rect; |
|
|
|
import android.util.AttributeSet; |
|
|
|
import android.util.AttributeSet; |
|
|
|
import android.util.Log; |
|
|
|
import android.util.Log; |
|
|
|
import android.view.SurfaceHolder; |
|
|
|
import android.view.SurfaceHolder; |
|
|
@ -44,6 +45,7 @@ public abstract class CameraBridgeViewBase extends SurfaceView implements Surfac |
|
|
|
protected int mFrameHeight; |
|
|
|
protected int mFrameHeight; |
|
|
|
protected int mMaxHeight; |
|
|
|
protected int mMaxHeight; |
|
|
|
protected int mMaxWidth; |
|
|
|
protected int mMaxWidth; |
|
|
|
|
|
|
|
protected float mScale = 0; |
|
|
|
protected int mPreviewFormat = Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA; |
|
|
|
protected int mPreviewFormat = Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA; |
|
|
|
protected int mCameraIndex = -1; |
|
|
|
protected int mCameraIndex = -1; |
|
|
|
protected boolean mEnabled; |
|
|
|
protected boolean mEnabled; |
|
|
@ -389,7 +391,22 @@ public abstract class CameraBridgeViewBase extends SurfaceView implements Surfac |
|
|
|
Canvas canvas = getHolder().lockCanvas(); |
|
|
|
Canvas canvas = getHolder().lockCanvas(); |
|
|
|
if (canvas != null) { |
|
|
|
if (canvas != null) { |
|
|
|
canvas.drawColor(0, android.graphics.PorterDuff.Mode.CLEAR); |
|
|
|
canvas.drawColor(0, android.graphics.PorterDuff.Mode.CLEAR); |
|
|
|
canvas.drawBitmap(mCacheBitmap, (canvas.getWidth() - mCacheBitmap.getWidth()) / 2, (canvas.getHeight() - mCacheBitmap.getHeight()) / 2, null); |
|
|
|
Log.d(TAG, "mStretch value: " + mScale); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mScale != 0) { |
|
|
|
|
|
|
|
canvas.drawBitmap(mCacheBitmap, new Rect(0,0,mCacheBitmap.getWidth(), mCacheBitmap.getHeight()), |
|
|
|
|
|
|
|
new Rect((int)((canvas.getWidth() - mScale*mCacheBitmap.getWidth()) / 2), |
|
|
|
|
|
|
|
(int)((canvas.getHeight() - mScale*mCacheBitmap.getHeight()) / 2), |
|
|
|
|
|
|
|
(int)((canvas.getWidth() - mScale*mCacheBitmap.getWidth()) / 2 + mScale*mCacheBitmap.getWidth()), |
|
|
|
|
|
|
|
(int)((canvas.getHeight() - mScale*mCacheBitmap.getHeight()) / 2 + mScale*mCacheBitmap.getHeight())), null); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
canvas.drawBitmap(mCacheBitmap, new Rect(0,0,mCacheBitmap.getWidth(), mCacheBitmap.getHeight()), |
|
|
|
|
|
|
|
new Rect((canvas.getWidth() - mCacheBitmap.getWidth()) / 2, |
|
|
|
|
|
|
|
(canvas.getHeight() - mCacheBitmap.getHeight()) / 2, |
|
|
|
|
|
|
|
(canvas.getWidth() - mCacheBitmap.getWidth()) / 2 + mCacheBitmap.getWidth(), |
|
|
|
|
|
|
|
(canvas.getHeight() - mCacheBitmap.getHeight()) / 2 + mCacheBitmap.getHeight()), null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mFpsMeter != null) { |
|
|
|
if (mFpsMeter != null) { |
|
|
|
mFpsMeter.measure(); |
|
|
|
mFpsMeter.measure(); |
|
|
|
mFpsMeter.draw(canvas, 20, 30); |
|
|
|
mFpsMeter.draw(canvas, 20, 30); |
|
|
|