Bitmap isRecycled - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Bitmap isRecycled method.

This code example shows how to use the following methods:getHeight, getWidth, isRecycled, hashCode
     
    private String describe(Bitmap b) {
        StringBuilder sb = new StringBuilder();
        if (b == null) {
            sb.append("NULL");
        } else if (b.isRecycled()) {
            sb.append(String.format("%08x: RECYCLED", b.hashCode()));
        } else { 
            sb.append(String.format("%08x: LIVE", b.hashCode()));
            sb.append(String.format("%d x %d (size == %d)", b.getWidth(), b.getHeight(), b.getWidth()*b.getHeight()*2));
        } 
        return sb.toString();
    } 
     
    public void dump() { 
        if (Config.LOGV) {
            Log.v(TAG, "dump ImageViewTouchBase " + this);
            Log.v(TAG, "... mBitmapDisplayed  = " + describe(mBitmapDisplayed));
            Log.v(TAG, "... mThumbBitmap      = " + describe(mThumbBitmap));
            Log.v(TAG, "... mFullBitmap       = " + describe(mFullBitmap));
7
CodeRank
This code example shows how to use the following methods:isRecycled, recycle
    } 
 
    public void disableCache() { 
        if (isCacheEnabled) {
            setDrawingCacheEnabled(false);
            if (cache != null && !cache.isRecycled()) {
                cache.recycle();
            } 
            isCacheEnabled = false;
            invalidate(); 
        } 
    } 
 
    @Override 
    protected void dispatchDraw(final Canvas canvas) {
        if (!isCacheEnabled) {
            super.dispatchDraw(canvas);
        } 
    } 
 
6
CodeRank
This code example shows how to use the following methods:compress, isRecycled, recycle
		return output;
	} 
 
	public static boolean saveBitmapToFile(final Bitmap bitmap, String savePath) {
		boolean result = false;
		if (bitmap != null && !bitmap.isRecycled()) {
			File myDrawFile = new File(savePath);
			try { 
				BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(myDrawFile));
				bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos);
				bos.flush();
				bos.close();
				result = true;
			} catch (Exception e) {
				Log.e("saveBitmapToFile", e);
			} finally { 
				if (bitmap != null) {
					bitmap.recycle();
				} 
			} 

7
CodeRank
This code example shows how to use the following methods:copy, isRecycled
    public void draw(final Canvas canvas) {
        if (isCacheEnabled) {
            if (cache == null || cache.isRecycled()) {
                updateCache(); 
            } 
            if (cache != null && !cache.isRecycled()) {
                canvas.drawBitmap(cache, null, new Rect(0, 0, getWidth(), getHeight()), paint);
            } 
        } else { 
            super.draw(canvas);
        } 
    } 
 
    public void enableCache() { 
        if (!isCacheEnabled && android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
            updateCache(); 
            isCacheEnabled = true;
        } 
    } 
 

6
CodeRank
This code example shows how to use the following methods:getHeight, getWidth, isRecycled
 
    // Superclass overrides 
 
    @Override 
    protected void onDraw(Canvas canvas) {
        if (mBitmap != null && mState != null && !mBitmap.isRecycled()) {
            final float aspectQuotient = mAspectQuotient.get();
 
            final int viewWidth = getWidth();
            final int viewHeight = getHeight();
            final int bitmapWidth = mBitmap.getWidth();
            final int bitmapHeight = mBitmap.getHeight();
 
            final float panX = mState.getPanX();
            final float panY = mState.getPanY();
            final float zoomX = mState.getZoomX(aspectQuotient) * viewWidth / bitmapWidth;
            final float zoomY = mState.getZoomY(aspectQuotient) * viewHeight / bitmapHeight;
 
            // Setup source and destination rectangles 
            mRectSrc.left = (int)(panX * bitmapWidth - viewWidth / (zoomX * 2));
6
CodeRank
This code example shows how to use the following methods:copy, isRecycled
    } 
 
    @Override 
    protected void dispatchDraw(final Canvas canvas) {
        if (isCacheEnabled) {
            if (cache == null || cache.isRecycled()) {
                updateCache(); 
            } 
            if (cache != null && !cache.isRecycled()) {
                canvas.drawBitmap(cache, null, new Rect(0, 0, getWidth(), getHeight()), paint);
            } 
        } else { 
            super.dispatchDraw(canvas);
        } 
    } 
 
    @Override 
    public void draw(final Canvas canvas) {
        if (!isCacheEnabled) {
            super.draw(canvas);
6
CodeRank
This code example shows how to use the following methods:isRecycled
		this(BitmapFactory.decodeStream(is));
	} 
 
	@Override 
	public void draw( Canvas canvas ) {
		if( null != mBitmap && !mBitmap.isRecycled() ) {
			canvas.drawBitmap( mBitmap, 0.0f, 0.0f, mPaint );
		} 
	} 
 
	@Override 
	public int getOpacity() { 
		return PixelFormat.TRANSLUCENT;
	} 
 
	@Override 
	public void setAlpha( int alpha ) {
		mPaint.setAlpha( alpha );
	} 
 
6
CodeRank
This code example shows how to use the following methods:getWidth, isRecycled
 
		updateDirection(); 
	} 
 
	protected void updateDirection() { 
		if (compassArrow == null || compassArrow.isRecycled() == true) {
			return; 
		} 
 
        // compass margins 
        int compassRoseWidth = compassArrow.getWidth();
        int compassRoseHeight = compassArrow.getWidth();
        int marginLeft = (getWidth() - compassRoseWidth) / 2;
        int marginTop = (getHeight() - compassRoseHeight) / 2;
 
        invalidate(marginLeft, marginTop, (marginLeft + compassRoseWidth), (marginTop + compassRoseHeight));
	} 
 
	@Override 
	protected void onDraw(Canvas canvas){
6
CodeRank
This code example shows how to use the following methods:isRecycled, recycle
		// TODO Auto-generated method stub 
	} 
 
	@Override 
	public void resetBitmap(Bitmap bitmap) {
		if (mBitmap != null && !mBitmap.isRecycled()) {
			mBitmap.recycle();
		} 
		mBitmap = bitmap;
	} 
 
	@Override 
	public void setBitmap(Bitmap bitmap) {
		mBitmap = bitmap;
 
	} 
 
	@Override 
	public Bitmap getBitmap() {
		return mBitmap;
5
CodeRank
This code example shows how to use the following methods:getPixels, isRecycled
		return Color.TRANSPARENT;
	} 
 
	public void getPixels(int[] pixels, int offset, int stride, int x, int y,
			int width, int height) {
		if (mWorkingBitmap != null && mWorkingBitmap.isRecycled() == false) {
			mWorkingBitmap.getPixels(pixels, offset, stride, x, y, width,
					height);
		} 
	} 
 
	public int getBitmapWidth() { 
		if (mWorkingBitmap == null) {
			return -1; 
		} 
		return mWorkingBitmap.getWidth();
	} 
 
	public int getBitmapHeight() { 
		if (mWorkingBitmap == null) {
5
CodeRank

Related Bitmap isRecycled Questions & Answers:

isRecycled Method Overview
Returns true if this bitmap has been recycled.
See Code Examples for other Android Bitmap Methods: