當前位置: 首頁>>代碼示例>>Java>>正文


Java SurfaceHolder.unlockCanvasAndPost方法代碼示例

本文整理匯總了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);
            }
        }
    }
 
開發者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.unlockCanvasAndPost方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。