本文整理汇总了Java中android.view.SurfaceHolder.unlockCanvasAndPost方法的典型用法代码示例。如果您正苦于以下问题:Java SurfaceHolder.unlockCanvasAndPost方法的具体用法?Java SurfaceHolder.unlockCanvasAndPost怎么用?Java SurfaceHolder.unlockCanvasAndPost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.SurfaceHolder
的用法示例。
在下文中一共展示了SurfaceHolder.unlockCanvasAndPost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processFrame
import android.view.SurfaceHolder; //导入方法依赖的package包/类
private void processFrame(Mat frame) {
Canvas canvas = null;
SurfaceHolder holder = mCameraProcessPreview.getHolder();
try {
canvas = holder.lockCanvas(null);
if (canvas != null) {
Bitmap result = ImageProcessing.preprocess(frame, mOpenCvCameraView.getWidth(), mOpenCvCameraView.getHeight());
canvas.drawBitmap(result, 0, 0, new Paint());
}
} finally {
if (canvas != null) {
holder.unlockCanvasAndPost(canvas);
}
}
}
示例2: onSurfaceChanged
import android.view.SurfaceHolder; //导入方法依赖的package包/类
@Override
public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) {
super.onSurfaceChanged(holder, format, width, height);
if (DOLOG)
Log.d(TAG, "onSurfaceChanged: width = [" + width + "], height = [" + height + "]");
display = new Display(BlockDropWallpaper.this);
if (height > width) {
scale = (float) width / (float) height;
yCenter = height / 2f;
} else {
scale = 0.8f;
yCenter = (height / scale) / (2f * scale);
}
xCenter = width / 2f;
if (getState() != STATE_PAUSED) {
// Manually redraw with the new dimensions (it won't redraw automatically when paused)
Canvas canvas = holder.lockCanvas();
draw(canvas);
holder.unlockCanvasAndPost(canvas);
}
}
示例3: onTouchEvent
import android.view.SurfaceHolder; //导入方法依赖的package包/类
@Override
public void onTouchEvent(MotionEvent event) {
if (touchmode != 0) {
double x = event.getX();
double y = event.getY();
pa.touch(x, y);
SurfaceHolder holder = getSurfaceHolder();
Canvas canvas = null;
try {
canvas = holder.lockCanvas();
if (canvas != null) {
pa.draw(canvas);
}
} finally {
if (canvas != null)
holder.unlockCanvasAndPost(canvas);
}
super.onTouchEvent(event);
}
}
示例4: onSurfaceChanged
import android.view.SurfaceHolder; //导入方法依赖的package包/类
@Override
public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) {
if((this.width != width || this.height != height)) {
this.width = width;
this.height = height;
pa.reinitialize(width, height);
Canvas canvas = null;
try {
canvas = holder.lockCanvas();
if (canvas != null) {
pa.draw(canvas);
}
} finally {
if (canvas != null)
holder.unlockCanvasAndPost(canvas);
}
}
}
示例5: draw
import android.view.SurfaceHolder; //导入方法依赖的package包/类
private void draw() {
SurfaceHolder holder = getSurfaceHolder();
Canvas canvas = null;
pa.update();
try {
canvas = holder.lockCanvas();
if (canvas != null) {
pa.draw(canvas);
}
} finally {
if (canvas != null)
holder.unlockCanvasAndPost(canvas);
}
handler.removeCallbacks(drawRunner);
if (isVisible()) {
handler.postDelayed(drawRunner, framerate);
}
}
示例6: surfaceCreated
import android.view.SurfaceHolder; //导入方法依赖的package包/类
@Override
public void surfaceCreated(SurfaceHolder holder) {
Canvas canvas = holder.lockCanvas();
if (canvas != null) {
canvas.drawRGB(0, 0, 0);
holder.unlockCanvasAndPost(canvas);
}
if (cameraHandle == 0) {
V4lJni.setRotate(mCameraId, 2); // 0��ʱ��90�ȣ� 1˳ʱ��90�ȣ� 2����ת, 3��ת180��
cameraHandle = V4lJni.openCameraExt(mCameraId, 1280, 960, 0);
}
// ������Ƶ�߳̿�ʼ
this.shouldStop = false;
this.mainLoop = new Thread(this);
this.mainLoop.start();
}
示例7: drawFrame
import android.view.SurfaceHolder; //导入方法依赖的package包/类
void drawFrame() {
final SurfaceHolder holder = getSurfaceHolder();
final Rect frame = holder.getSurfaceFrame();
final int width = frame.width();
final int height = frame.height();
Canvas c = null;
try {
c = holder.lockCanvas();
if (c != null) {
// draw something
drawCube(c);
drawTouchPoint(c);
}
} finally {
if (c != null) holder.unlockCanvasAndPost(c);
}
mHandler.removeCallbacks(mDrawCube);
if (mVisible) {
mHandler.postDelayed(mDrawCube, 1000 / 25);
}
}
示例8: drawFrame
import android.view.SurfaceHolder; //导入方法依赖的package包/类
void drawFrame() {
final SurfaceHolder holder = getSurfaceHolder();
Canvas c = null;
try {
c = holder.lockCanvas();
if (c != null) {
// draw something
drawCube(c);
drawTouchPoint(c);
}
} finally {
if (c != null) holder.unlockCanvasAndPost(c);
}
// Reschedule the next redraw
mHandler.removeCallbacks(mDrawCube);
if (mVisible) {
mHandler.postDelayed(mDrawCube, 1000 / 25);
}
}
示例9: draw
import android.view.SurfaceHolder; //导入方法依赖的package包/类
private void draw() {
final SurfaceHolder holder = getSurfaceHolder();
Canvas canvas = null;
try {
canvas = holder.lockCanvas();
if (canvas != null) {
// Draw the frame here.
drawFrame(canvas);
}
} finally {
if (canvas != null) {
holder.unlockCanvasAndPost(canvas);
}
}
handler.removeCallbacks(drawRunnable);
if (visible) {
handler.postDelayed(drawRunnable, 5000);
}
}
示例10: draw
import android.view.SurfaceHolder; //导入方法依赖的package包/类
/**
* Draw
*/
private void draw() {
long t = System.currentTimeMillis();
SurfaceHolder holder = getSurfaceHolder();
Canvas canvas = null;
try {
canvas = holder.lockCanvas();
canvas.drawColor(backgroundColor);
if (useBackgroundImage) {
tilingAndDraw(backgroundImage, canvas);
}
for (ToDraw actual : objects) {
doubles.clear();
moveObject(actual, t - time);
//draw the doubles before the reel objects, to keep the screen from flashing!
for (ToDraw td : doubles) {
drawOnCanvas(td, canvas);
}
drawOnCanvas(actual, canvas);
}
} finally {
if (canvas != null) {
holder.unlockCanvasAndPost(canvas);
}
}
time = t;
handler.removeCallbacks(drawRunner);
if (visibility) {
handler.postDelayed(drawRunner, sleepBetweenRedraws);
}
}
示例11: surfaceCreated
import android.view.SurfaceHolder; //导入方法依赖的package包/类
@Override
public void surfaceCreated(SurfaceHolder holder) {
mUsbMonitor.register();
mUsbMonitor.requestPermission(getCamDev(mCameraId));
Canvas canvas = holder.lockCanvas();
if (canvas != null) {
canvas.drawRGB(0, 0, 0);
holder.unlockCanvasAndPost(canvas);
}
this.shouldStop = false;
this.mainLoop = new Thread(this);
this.mainLoop.start();
}
示例12: surfaceCreated
import android.view.SurfaceHolder; //导入方法依赖的package包/类
public void surfaceCreated(SurfaceHolder surfaceHolder) {
this.isSurfaceCreated = true;
Canvas canvas = surfaceHolder.lockCanvas();
if (canvas != null) {
DrawHelper.clearCanvas(canvas);
surfaceHolder.unlockCanvasAndPost(canvas);
}
}
示例13: draw
import android.view.SurfaceHolder; //导入方法依赖的package包/类
private void draw() {
SurfaceHolder surfaceHolder = getSurfaceHolder();
Canvas canvas = null;
Calendar ca = Calendar.getInstance();
try {
canvas = surfaceHolder.lockCanvas();
if (canvas != null) {
paint.setTypeface(getTypeface());
paint.setAntiAlias(true);
paint.setTextAlign(Paint.Align.CENTER);
paint.setTextSize(TextSizePreference.getValue());
int xPos = (canvas.getWidth() / 2);
int yPos = (int) ((canvas.getHeight() / 2) - ((paint.descent() + paint.ascent()) / 2)) ;
canvas.drawColor(Color.parseColor(getTimeColor(ca)));
canvas.drawText(getTimeText(ca), xPos, yPos, paint);
}
}
finally {
if(canvas != null) {
surfaceHolder.unlockCanvasAndPost(canvas);
}
}
handler.removeCallbacks(runnable);
if(visible) {
handler.postDelayed(runnable, 100);
}
}
示例14: drawSurfaceView
import android.view.SurfaceHolder; //导入方法依赖的package包/类
private void drawSurfaceView(SurfaceHolder holder) {
if (this.mNextBitmap != null && !this.mNextBitmap.isRecycled()) {
Canvas localCanvas = holder.lockCanvas();
if (localCanvas != null) {
Rect rect = new Rect();
rect.left = rect.top = 0;
rect.bottom = localCanvas.getHeight();
rect.right = localCanvas.getWidth();
localCanvas.drawBitmap(this.mNextBitmap, null, rect, this.mPaint);
holder.unlockCanvasAndPost(localCanvas);
}
}
}
示例15: surfaceCreated
import android.view.SurfaceHolder; //导入方法依赖的package包/类
@Override
public void surfaceCreated(SurfaceHolder surfaceHolder) {
isSurfaceCreated = true;
Canvas canvas = surfaceHolder.lockCanvas();
if (canvas != null) {
DrawHelper.clearCanvas(canvas);
surfaceHolder.unlockCanvasAndPost(canvas);
}
}