Android Picture - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Picture class.

This code example shows how to use the following methods:draw, getHeight, getWidth
	 *  
	 */ 
 
	private Bitmap getBitmapOfWebView(final WebView webView){
		Picture picture = webView.capturePicture();
		Bitmap b = Bitmap.createBitmap( picture.getWidth(), picture.getHeight(), Bitmap.Config.ARGB_8888);
		Canvas c = new Canvas(b);
		picture.draw(c);
		return b;
	} 
 
	/** 
	 * Returns a bitmap of a given View. 
	 *  
	 * @param view the view to save a bitmap from 
	 * @return a bitmap of the given view 
	 *  
	 */ 
 
	private Bitmap getBitmapOfView(final View view){
8
CodeRank
This code example shows how to use the following methods:beginRecording, endRecording
     * Creates a new Picture that records drawing a provided bitmap. 
     * Will return an empty Picture if the Bitmap is null. 
     */ 
    @CalledByNative 
    private static Picture recordBitmapIntoPicture(Bitmap bitmap) {
        Picture picture = new Picture();
        if (bitmap != null) {
            Canvas recordingCanvas = picture.beginRecording(bitmap.getWidth(), bitmap.getHeight());
            drawBitmapIntoCanvas(bitmap, recordingCanvas);
            picture.endRecording();
        } 
        return picture;
    } 
 
    // Should never be instantiated. 
    private JavaBrowserViewRendererHelper() { 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:getHeight, getWidth
    } 
     
    public void setBitmap(WebView view)
    { 
        Picture p = view.capturePicture();
        state = Bitmap.createBitmap(p.getWidth(), p.getHeight(), Bitmap.Config.ARGB_8888);
    } 
     
    public boolean checkRenderView(WebView view)
    { 
        if(state == null)
        { 
            setBitmap(view);
            return false; 
        } 
        else 
        { 
            Picture p = view.capturePicture();
            Bitmap newState = Bitmap.createBitmap(p.getWidth(), p.getHeight(), Bitmap.Config.ARGB_8888);
            boolean result = newState.equals(state);
7
CodeRank
This code example shows how to use the following methods:beginRecording, endRecording
        canvas.restore();
    } 
 
    @Override 
    protected void dispatchDraw(Canvas canvas) {
        super.dispatchDraw(mPicture.beginRecording(getWidth(), getHeight()));
        mPicture.endRecording();
 
        int x = getWidth()/2;
        int y = getHeight()/2;
 
        if (false) { 
            canvas.drawPicture(mPicture);
        } else { 
            drawPict(canvas, 0, 0, x, y,  1,  1);
            drawPict(canvas, x, 0, x, y, -1,  1);
            drawPict(canvas, 0, y, x, y,  1, -1);
            drawPict(canvas, x, y, x, y, -1, -1);
        } 
    } 
7
CodeRank
This code example shows how to use the following methods:beginRecording, draw, endRecording, getHeight, getWidth
		// mScale); 
		final int picBorderWidthAndHeight = (int) ((mCompassRadius + 5) * 2);
		final int center = picBorderWidthAndHeight / 2;
 
		// Record Rose 
		Picture mCompassRose = new Picture();
		final Canvas canvas = mCompassRose.beginRecording(picBorderWidthAndHeight, picBorderWidthAndHeight);
 
		// Blue triangle pointing north 
		final Path pathNorth = new Path();
		pathNorth.moveTo(center, center - (mCompassRadius - 3) * mScale);
		pathNorth.lineTo(center + 4 * mScale, center);
		pathNorth.lineTo(center - 4 * mScale, center);
		pathNorth.lineTo(center, center - (mCompassRadius - 3) * mScale);
		pathNorth.close();
		canvas.drawPath(pathNorth, northPaint);
 
		// Red triangle pointing south 
		final Path pathSouth = new Path();
		pathSouth.moveTo(center, center + (mCompassRadius - 3) * mScale);

6
CodeRank
This code example shows how to use the following methods:beginRecording, draw, endRecording, getHeight, getWidth
6
CodeRank
This code example shows how to use the following methods:beginRecording, endRecording
This code example shows how to use the following methods:getHeight, getWidth
    } 
     
    public void setBitmap(WebView view)
    { 
        Picture p = view.capturePicture();
        state = Bitmap.createBitmap(p.getWidth(), p.getHeight(), Bitmap.Config.ARGB_8888);
    } 
     
    public boolean checkRenderView(WebView view)
    { 
        if(state == null)
        { 
            setBitmap(view);
            return false; 
        } 
        else 
        { 
            Picture p = view.capturePicture();
            Bitmap newState = Bitmap.createBitmap(p.getWidth(), p.getHeight(), Bitmap.Config.ARGB_8888);
            boolean result = newState.equals(state);
6
CodeRank
This code example shows how to use the following methods:beginRecording, draw, endRecording, getHeight, getWidth
        // Compute Draw 
 
    } 
 
    // @Override 
    public void onSubBackground(Canvas canvas) {
        if (Log.isLoggable(TAG, Log.DEBUG)) {
            Log.d(TAG, String.format(" width = %s  // height = %s", getWidth(), getHeight()));
        } 
        mCompassMatrix.setRotate(-bearing, COMPASS_ROSE_CENTER_X, COMPASS_ROSE_CENTER_Y);
        mCompassMatrix.postTranslate(-COMPASS_ROSE_CENTER_X, -COMPASS_ROSE_CENTER_Y);
        mCompassMatrix.postTranslate(centerX, centerY);
        canvas.drawBitmap(compassRose, mCompassMatrix, mPaint);
 
    } 
 
    /** 
     * This is called during layout when the size of this view has changed. If 
     * you were just added to the view hierarchy, you're called with the old 
     * values of 0. 

6
CodeRank
This code example shows how to use the following methods:draw, getHeight, getWidth
		} 
 
		final Bitmap bitmap = Bitmap.createBitmap(this.mWidth, this.mHeight, pBitmapConfig);
		final Canvas canvas = new Canvas(bitmap);
 
		final float scaleX = (float)this.mWidth / this.mPicture.getWidth();
		final float scaleY = (float)this.mHeight / this.mPicture.getHeight();
		canvas.scale(scaleX, scaleY, 0, 0);
 
		picture.draw(canvas);
 
		return bitmap;
	} 
 
	// =========================================================== 
	// Methods 
	// =========================================================== 
 
	// =========================================================== 
	// Inner and Anonymous Classes 
6
CodeRank

Related Android Picture Questions & Answers:

See Code Examples for Android Picture Methods: