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


Java Bitmap.isRecycled方法代码示例

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


在下文中一共展示了Bitmap.isRecycled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: putNewShot

import android.graphics.Bitmap; //导入方法依赖的package包/类
public void putNewShot(Bitmap bitmap) {
    if (bitmap == null || bitmap.isRecycled()) {
        return;
    }

    mLastShotMills = System.currentTimeMillis();
    if (startShotBitmap == null) {
        startShotBitmap = bitmap;
        return;
    }

    if (duration == 0 && endShotBitmap != null) {
        if (endSecondShotBitmap != null) {
            endSecondShotBitmap.recycle();
        }

        endSecondShotBitmap = endShotBitmap;
    }

    endShotBitmap = bitmap;
}
 
开发者ID:monthlypub,项目名称:SmingZZick_App,代码行数:22,代码来源:SmingData.java

示例2: share

import android.graphics.Bitmap; //导入方法依赖的package包/类
public boolean share(Platform plat, HashMap<String, Object> data) {
    if (plat == null || data == null) {
        return false;
    }
    try {
        Bitmap viewToShare = (Bitmap) data.get("viewToShare");
        if (!(!TextUtils.isEmpty((String) data.get("imagePath")) || viewToShare == null || viewToShare.isRecycled())) {
            File ss = new File(R.getCachePath(plat.getContext(), "screenshot"), String.valueOf(System.currentTimeMillis()) + ".jpg");
            FileOutputStream fos = new FileOutputStream(ss);
            viewToShare.compress(CompressFormat.JPEG, 100, fos);
            fos.flush();
            fos.close();
            data.put("imagePath", ss.getAbsolutePath());
        }
        ShareParams sp = new ShareParams((HashMap) data);
        if (this.customizeCallback != null) {
            this.customizeCallback.onShare(plat, sp);
        }
        plat.share(sp);
        return true;
    } catch (Throwable t) {
        t.printStackTrace();
        return false;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:26,代码来源:ShareCore.java

示例3: shareDataToShareParams

import android.graphics.Bitmap; //导入方法依赖的package包/类
final ShareParams shareDataToShareParams(Platform plat) {
	if (plat == null || shareParamsMap == null) {
		toast("ssdk_oks_share_failed");
		return null;
	}

	try {
		String imagePath = ResHelper.forceCast(shareParamsMap.get("imagePath"));
		Bitmap viewToShare = ResHelper.forceCast(shareParamsMap.get("viewToShare"));
		if (TextUtils.isEmpty(imagePath) && viewToShare != null && !viewToShare.isRecycled()) {
			String path = ResHelper.getCachePath(plat.getContext(), "screenshot");
			File ss = new File(path, String.valueOf(System.currentTimeMillis()) + ".jpg");
			FileOutputStream fos = new FileOutputStream(ss);
			viewToShare.compress(CompressFormat.JPEG, 100, fos);
			fos.flush();
			fos.close();
			shareParamsMap.put("imagePath", ss.getAbsolutePath());
		}
	} catch (Throwable t) {
		t.printStackTrace();
		toast("ssdk_oks_share_failed");
		return null;
	}

	return new ShareParams(shareParamsMap);
}
 
开发者ID:auv1107,项目名称:TextEmoji,代码行数:27,代码来源:OnekeyShareThemeImpl.java

示例4: toBitmap

import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
 * 把view转化为bitmap(截图)
 * 参见:http://www.cnblogs.com/lee0oo0/p/3355468.html
 */
public static Bitmap toBitmap(View view) {
    int width = view.getWidth();
    int height = view.getHeight();
    if (view instanceof ListView) {
        height = 0;
        // 获取listView实际高度
        ListView listView = (ListView) view;
        for (int i = 0; i < listView.getChildCount(); i++) {
            height += listView.getChildAt(i).getHeight();
        }
    } else if (view instanceof ScrollView) {
        height = 0;
        // 获取scrollView实际高度
        ScrollView scrollView = (ScrollView) view;
        for (int i = 0; i < scrollView.getChildCount(); i++) {
            height += scrollView.getChildAt(i).getHeight();
        }
    }
    view.setDrawingCacheEnabled(true);
    view.clearFocus();
    view.setPressed(false);
    boolean willNotCache = view.willNotCacheDrawing();
    view.setWillNotCacheDrawing(false);
    // Reset the drawing cache background color to fully transparent for the duration of this operation
    int color = view.getDrawingCacheBackgroundColor();
    view.setDrawingCacheBackgroundColor(Color.WHITE);//截图去黑色背景(透明像素)
    if (color != Color.WHITE) {
        view.destroyDrawingCache();
    }
    view.buildDrawingCache();
    Bitmap cacheBitmap = view.getDrawingCache();
    if (cacheBitmap == null) {
        return null;
    }
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.drawBitmap(cacheBitmap, 0, 0, null);
    canvas.save(Canvas.ALL_SAVE_FLAG);
    canvas.restore();
    if (!bitmap.isRecycled()) {
        LogUtils.verbose("recycle bitmap: " + bitmap.toString());
        bitmap.recycle();
    }
    // Restore the view
    view.destroyDrawingCache();
    view.setWillNotCacheDrawing(willNotCache);
    view.setDrawingCacheBackgroundColor(color);
    return bitmap;
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:54,代码来源:ConvertUtils.java

示例5: destroy

import android.graphics.Bitmap; //导入方法依赖的package包/类
public void destroy() {
    for (Bitmap bitmap : bitmaps) {
        if (bitmap != null && !bitmap.isRecycled()) {
            bitmap.recycle();
        }
    }

}
 
开发者ID:florent37,项目名称:Depth,代码行数:9,代码来源:RenderableBear.java

示例6: addReflection

import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
 * 添加倒影
 *
 * @param src              源图片的
 * @param reflectionHeight 倒影高度
 * @param recycle          是否回收
 * @return 带倒影图片
 */
public static Bitmap addReflection(Bitmap src, int reflectionHeight, boolean recycle) {
    if (isEmptyBitmap(src)) return null;
    // 原图与倒影之间的间距
    final int REFLECTION_GAP = 0;
    int srcWidth = src.getWidth();
    int srcHeight = src.getHeight();
    Matrix matrix = new Matrix();
    matrix.preScale(1, -1);
    Bitmap reflectionBitmap = Bitmap.createBitmap(src, 0, srcHeight - reflectionHeight,
            srcWidth, reflectionHeight, matrix, false);
    Bitmap ret = Bitmap.createBitmap(srcWidth, srcHeight + reflectionHeight, src.getConfig());
    Canvas canvas = new Canvas(ret);
    canvas.drawBitmap(src, 0, 0, null);
    canvas.drawBitmap(reflectionBitmap, 0, srcHeight + REFLECTION_GAP, null);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    LinearGradient shader = new LinearGradient(0, srcHeight,
            0, ret.getHeight() + REFLECTION_GAP,
            0x70FFFFFF, 0x00FFFFFF, Shader.TileMode.MIRROR);
    paint.setShader(shader);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
    canvas.drawRect(0, srcHeight + REFLECTION_GAP,
            srcWidth, ret.getHeight(), paint);
    if (!reflectionBitmap.isRecycled()) reflectionBitmap.recycle();
    if (recycle && !src.isRecycled()) src.recycle();
    return ret;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:36,代码来源:ImageUtils.java

示例7: setImageBitmap

import android.graphics.Bitmap; //导入方法依赖的package包/类
public void setImageBitmap(Bitmap bitmap) {
	if (bitmap == null || bitmap.isRecycled())
		return;
	mImageWidth = bitmap.getWidth();
	mImageHeight = bitmap.getHeight();
	mOriginBitmap = bitmap;
	adjustImageDisplaySize();
	mMagicSDK.storeBitmap(mOriginBitmap, false);
	refreshDisplay();
}
 
开发者ID:smartbeng,项目名称:PaoMovie,代码行数:11,代码来源:MagicMovieDisplay.java

示例8: toGray

import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
 * 转为灰度图片
 *
 * @param src     源图片
 * @param recycle 是否回收
 * @return 灰度图
 */
public static Bitmap toGray(Bitmap src, boolean recycle) {
    if (isEmptyBitmap(src)) return null;
    Bitmap grayBitmap = Bitmap.createBitmap(src.getWidth(),
            src.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(grayBitmap);
    Paint paint = new Paint();
    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.setSaturation(0);
    ColorMatrixColorFilter colorMatrixColorFilter = new ColorMatrixColorFilter(colorMatrix);
    paint.setColorFilter(colorMatrixColorFilter);
    canvas.drawBitmap(src, 0, 0, paint);
    if (recycle && !src.isRecycled()) src.recycle();
    return grayBitmap;
}
 
开发者ID:tututututututu,项目名称:BaseCore,代码行数:22,代码来源:ImageUtils.java

示例9: isRecycled

import android.graphics.Bitmap; //导入方法依赖的package包/类
protected boolean isRecycled() {
	if(drawable != null && drawable instanceof BitmapDrawable) {
		Bitmap bitmap = ((BitmapDrawable)drawable).getBitmap();
		if(bitmap != null) {
			return bitmap.isRecycled();
		}
	}
	return false;
}
 
开发者ID:CactusSoft,项目名称:zabbkit-android,代码行数:10,代码来源:GestureImageView.java

示例10: returnBitmap

import android.graphics.Bitmap; //导入方法依赖的package包/类
@Override
public void returnBitmap(Bitmap bmp) {
    if (bmp != null && !bmp.isRecycled()) {
        Handler h = new Handler(Looper.getMainLooper());
        h.post(() -> {
            h.post(() -> {
                bmp.recycle();
            });
        });
    }
}
 
开发者ID:worldiety,项目名称:homunculus,代码行数:12,代码来源:BitmapPoolFactory.java

示例11: getRotateBitmap

import android.graphics.Bitmap; //导入方法依赖的package包/类
public static Bitmap getRotateBitmap(Bitmap bitmap, int rotation){
	if(null == bitmap || bitmap.isRecycled()){
		return null;
	}
	
	Matrix matrix = new Matrix();
	matrix.postRotate(rotation);
	Bitmap cropBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),bitmap.getHeight(), matrix, false);
	return cropBitmap;
}
 
开发者ID:zhangyaqiang,项目名称:Fatigue-Detection,代码行数:11,代码来源:STUtils.java

示例12: getView

import android.graphics.Bitmap; //导入方法依赖的package包/类
public View getView(int position, View convertView, ViewGroup parent) {
    FollowListItem item;
    boolean simpleMode = "FacebookMessenger".equals(this.platform.getName());
    if (convertView == null) {
        View llItem = new LinearLayout(parent.getContext());
        item = new FollowListItem();
        llItem.setTag(item);
        convertView = llItem;
        int dp_52 = R.dipToPx(getContext(), 52);
        int dp_10 = R.dipToPx(parent.getContext(), 10);
        int dp_5 = R.dipToPx(parent.getContext(), 5);
        if (!simpleMode) {
            item.aivIcon = new AsyncImageView(getContext());
            LayoutParams lpIcon = new LayoutParams(dp_52, dp_52);
            lpIcon.gravity = 16;
            lpIcon.setMargins(dp_10, dp_5, dp_10, dp_5);
            item.aivIcon.setLayoutParams(lpIcon);
            llItem.addView(item.aivIcon);
        }
        LinearLayout llText = new LinearLayout(parent.getContext());
        llText.setPadding(0, dp_10, dp_10, dp_10);
        llText.setOrientation(1);
        LayoutParams lpText = new LayoutParams(-2, -2);
        lpText.gravity = 16;
        lpText.weight = 1.0f;
        llText.setLayoutParams(lpText);
        llItem.addView(llText);
        item.tvName = new TextView(parent.getContext());
        item.tvName.setTextColor(-16777216);
        item.tvName.setTextSize(1, 18.0f);
        item.tvName.setSingleLine();
        if (simpleMode) {
            item.tvName.setPadding(dp_10, 0, 0, 0);
        }
        llText.addView(item.tvName);
        if (!simpleMode) {
            item.tvSign = new TextView(parent.getContext());
            item.tvSign.setTextColor(2130706432);
            item.tvSign.setTextSize(1, 14.0f);
            item.tvSign.setSingleLine();
            llText.addView(item.tvSign);
        }
        item.ivCheck = new ImageView(parent.getContext());
        item.ivCheck.setPadding(0, 0, dp_10, 0);
        LayoutParams lpCheck = new LayoutParams(-2, -2);
        lpCheck.gravity = 16;
        item.ivCheck.setLayoutParams(lpCheck);
        llItem.addView(item.ivCheck);
    } else {
        item = (FollowListItem) convertView.getTag();
    }
    Following following = getItem(position);
    item.tvName.setText(following.screenName);
    if (!simpleMode) {
        item.tvSign.setText(following.description);
    }
    item.ivCheck.setImageBitmap(following.checked ? this.bmChd : this.bmUnch);
    if (!simpleMode) {
        if (isFling()) {
            Bitmap bm = BitmapProcessor.getBitmapFromCache(following.icon);
            if (bm == null || bm.isRecycled()) {
                item.aivIcon.execute(null, 0);
            } else {
                item.aivIcon.setImageBitmap(bm);
            }
        } else {
            item.aivIcon.execute(following.icon, 0);
        }
    }
    if (position == getCount() - 1) {
        next();
    }
    return convertView;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:75,代码来源:FollowListPage.java

示例13: fastBlur

import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
 * 快速模糊图片
 * <p>先缩小原图,对小图进行模糊,再放大回原先尺寸</p>
 *
 * @param src     源图片
 * @param scale   缩放比例(0...1)
 * @param radius  模糊半径
 * @param recycle 是否回收
 * @return 模糊后的图片
 */
public static Bitmap fastBlur(Bitmap src, float scale, float radius, boolean recycle) {
    if (isEmptyBitmap(src)) return null;
    int width = src.getWidth();
    int height = src.getHeight();
    int scaleWidth = (int) (width * scale + 0.5f);
    int scaleHeight = (int) (height * scale + 0.5f);
    if (scaleWidth == 0 || scaleHeight == 0) return null;
    Bitmap scaleBitmap = Bitmap.createScaledBitmap(src, scaleWidth, scaleHeight, true);
    Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);
    Canvas canvas = new Canvas();
    PorterDuffColorFilter filter = new PorterDuffColorFilter(
            Color.TRANSPARENT, PorterDuff.Mode.SRC_ATOP);
    paint.setColorFilter(filter);
    canvas.scale(scale, scale);
    canvas.drawBitmap(scaleBitmap, 0, 0, paint);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        scaleBitmap = renderScriptBlur(Utils.getContext(), scaleBitmap, radius);
    } else {
        scaleBitmap = stackBlur(scaleBitmap, (int) radius, recycle);
    }
    if (scale == 1) return scaleBitmap;
    Bitmap ret = Bitmap.createScaledBitmap(scaleBitmap, width, height, true);
    if (scaleBitmap != null && !scaleBitmap.isRecycled()) scaleBitmap.recycle();
    if (recycle && !src.isRecycled()) src.recycle();
    return ret;
}
 
开发者ID:tututututututu,项目名称:BaseCore,代码行数:37,代码来源:ImageUtils.java

示例14: compressBySampleSize

import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
 * 按采样大小压缩
 *
 * @param src        源图片
 * @param sampleSize 采样率大小
 * @param recycle    是否回收
 * @return 按采样率压缩后的图片
 */
public static Bitmap compressBySampleSize(Bitmap src, int sampleSize, boolean recycle) {
    if (isEmptyBitmap(src)) return null;
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inSampleSize = sampleSize;
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    src.compress(Bitmap.CompressFormat.JPEG, 100, baos);
    byte[] bytes = baos.toByteArray();
    if (recycle && !src.isRecycled()) src.recycle();
    return BitmapFactory.decodeByteArray(bytes, 0, bytes.length, options);
}
 
开发者ID:pan2yong22,项目名称:AndroidUtilCode-master,代码行数:19,代码来源:ImageUtils.java

示例15: rotaingImageView

import android.graphics.Bitmap; //导入方法依赖的package包/类
private Bitmap rotaingImageView(int angle, Bitmap bitmap) {
    Matrix matrix = new Matrix();
    matrix.postRotate((float)angle);
    Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
    if(resizedBitmap != bitmap && bitmap != null && !bitmap.isRecycled()) {
        bitmap.recycle();
        bitmap = null;
    }

    return resizedBitmap;
}
 
开发者ID:xiaoyaoyou1212,项目名称:ViseFace,代码行数:12,代码来源:FaceDetectorActivity.java


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