当前位置: 首页>>代码示例>>Java>>正文


Java SurfaceHolder.lockCanvas方法代码示例

本文整理汇总了Java中android.view.SurfaceHolder.lockCanvas方法的典型用法代码示例。如果您正苦于以下问题:Java SurfaceHolder.lockCanvas方法的具体用法?Java SurfaceHolder.lockCanvas怎么用?Java SurfaceHolder.lockCanvas使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.SurfaceHolder的用法示例。


在下文中一共展示了SurfaceHolder.lockCanvas方法的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);
            }
        }
    }
 
开发者ID:jorenham,项目名称:fingerblox,代码行数:18,代码来源:MainActivity.java

示例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);
    }
}
 
开发者ID:StringMon,项目名称:homescreenarcade,代码行数:25,代码来源:BlockDropWallpaper.java

示例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);
	}
}
 
开发者ID:connyduck,项目名称:pixelwallpaper,代码行数:25,代码来源:PixelWallpaperService.java

示例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);
		}

	}

}
 
开发者ID:connyduck,项目名称:pixelwallpaper,代码行数:25,代码来源:PixelWallpaperService.java

示例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);
			}

		}
 
开发者ID:connyduck,项目名称:pixelwallpaper,代码行数:25,代码来源:PixelWallpaperService.java

示例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();
  }
 
开发者ID:wjchen,项目名称:AndroidUvcCameras,代码行数:17,代码来源:CameraPreviewV4L.java

示例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);
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:24,代码来源:CubeWallpaper2.java

示例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);
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:22,代码来源:CubeWallpaper1.java

示例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);
    }
}
 
开发者ID:arunkumar9t2,项目名称:chameleon-live-wallpaper,代码行数:20,代码来源:ChameleonWallpaperService.java

示例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);
    }
}
 
开发者ID:samsumas,项目名称:LivingBurger,代码行数:34,代码来源:JumpingBurger.java

示例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();
}
 
开发者ID:wjchen,项目名称:AndroidUvcCameras,代码行数:16,代码来源:CameraPreviewUVC.java

示例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);
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:9,代码来源:DanmakuSurfaceView.java

示例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);
    }
}
 
开发者ID:jajasuperman,项目名称:HexColorTime,代码行数:34,代码来源:Wallpaper.java

示例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);
        }
    }
}
 
开发者ID:coolspan,项目名称:LiveWallpaper,代码行数:14,代码来源:LiveWallpaperView.java

示例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);
    }
}
 
开发者ID:lisnstatic,项目名称:live_master,代码行数:10,代码来源:DanmakuSurfaceView.java


注:本文中的android.view.SurfaceHolder.lockCanvas方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。