本文整理了Java中android.graphics.Bitmap.isMutable()
方法的一些代码示例,展示了Bitmap.isMutable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bitmap.isMutable()
方法的具体详情如下:
包路径:android.graphics.Bitmap
类名称:Bitmap
方法名:isMutable
暂无
代码示例来源:origin: koral--/android-gif-drawable
/**
* Retrieves a copy of currently buffered frame.
*
* @return current frame
*/
public Bitmap getCurrentFrame() {
final Bitmap copy = mBuffer.copy(mBuffer.getConfig(), mBuffer.isMutable());
copy.setHasAlpha(mBuffer.hasAlpha());
return copy;
}
代码示例来源:origin: square/assertj-android
public BitmapAssert isMutable() {
isNotNull();
assertThat(actual.isMutable()) //
.overridingErrorMessage("Expected to be mutable but was not mutable.") //
.isTrue();
return this;
}
代码示例来源:origin: square/assertj-android
public BitmapAssert isNotMutable() {
isNotNull();
assertThat(actual.isMutable()) //
.overridingErrorMessage("Expected to not be mutable but was mutable.") //
.isFalse();
return this;
}
代码示例来源:origin: bumptech/glide
@Override
public synchronized void put(Bitmap bitmap) {
if (bitmap == null) {
throw new NullPointerException("Bitmap must not be null");
}
if (bitmap.isRecycled()) {
throw new IllegalStateException("Cannot pool recycled bitmap");
}
if (!bitmap.isMutable() || strategy.getSize(bitmap) > maxSize
|| !allowedConfigs.contains(bitmap.getConfig())) {
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "Reject bitmap from pool"
+ ", bitmap: " + strategy.logBitmap(bitmap)
+ ", is mutable: " + bitmap.isMutable()
+ ", is allowed config: " + allowedConfigs.contains(bitmap.getConfig()));
}
bitmap.recycle();
return;
}
final int size = strategy.getSize(bitmap);
strategy.put(bitmap);
tracker.add(bitmap);
puts++;
currentSize += size;
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "Put bitmap in pool=" + strategy.logBitmap(bitmap));
}
dump();
evict();
}
代码示例来源:origin: bumptech/glide
public void isImmutable() {
if (actual().isMutable()) {
fail("is immutable");
}
}
代码示例来源:origin: bumptech/glide
public void isMutable() {
if (!actual().isMutable()) {
fail("is mutable");
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldCreateMutableBitmap() throws Exception {
Bitmap mutableBitmap = Bitmap.createBitmap(100, 200, Bitmap.Config.ARGB_8888);
assertThat(mutableBitmap.isMutable()).isTrue();
}
代码示例来源:origin: robolectric/robolectric
@Test
@Config(minSdk = JELLY_BEAN_MR1)
public void shouldCreateMutableBitmapWithDisplayMetrics() throws Exception {
final DisplayMetrics metrics = new DisplayMetrics();
metrics.densityDpi = 1000;
final Bitmap bitmap = Bitmap.createBitmap(metrics, 100, 100, Bitmap.Config.ARGB_8888);
assertThat(bitmap.isMutable()).isTrue();
assertThat(bitmap.getDensity()).isEqualTo(1000);
}
代码示例来源:origin: robolectric/robolectric
@Config(minSdk = P)
@SdkSuppress(minSdkVersion = P)
@Test public void createBitmap() {
Picture picture = new Picture();
Canvas canvas = picture.beginRecording(200, 100);
Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
p.setColor(0x88FF0000);
canvas.drawCircle(50, 50, 40, p);
p.setColor(Color.GREEN);
p.setTextSize(30);
canvas.drawText("Pictures", 60, 60, p);
picture.endRecording();
Bitmap bitmap = Bitmap.createBitmap(picture);
assertThat(bitmap.isMutable()).isFalse();
}
代码示例来源:origin: chrisbanes/Android-BitmapCache
public synchronized boolean isBitmapMutable() {
Bitmap bitmap = getBitmap();
return null != bitmap && bitmap.isMutable();
}
代码示例来源:origin: guolindev/giffun
@Override
public synchronized boolean put(Bitmap bitmap) {
if (bitmap == null) {
throw new NullPointerException("Bitmap must not be null");
}
if (!bitmap.isMutable() || strategy.getSize(bitmap) > maxSize || !allowedConfigs.contains(bitmap.getConfig())) {
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "Reject bitmap from pool"
+ ", bitmap: " + strategy.logBitmap(bitmap)
+ ", is mutable: " + bitmap.isMutable()
+ ", is allowed config: " + allowedConfigs.contains(bitmap.getConfig()));
}
return false;
}
final int size = strategy.getSize(bitmap);
strategy.put(bitmap);
tracker.add(bitmap);
puts++;
currentSize += size;
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "Put bitmap in pool=" + strategy.logBitmap(bitmap));
}
dump();
evict();
return true;
}
代码示例来源:origin: stackoverflow.com
Bitmap bitmap=BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher);
final JniBitmapHolder bitmapHolder=new JniBitmapHolder(bitmap);
bitmap.recycle();
bitmap=bitmapHolder.getBitmapAndFree();
Log.d("DEBUG",""+bitmap.isMutable()); //will return true
代码示例来源:origin: stackoverflow.com
private Bitmap adjustOpacity(Bitmap bitmap, int opacity)
{
Bitmap mutableBitmap = bitmap.isMutable()
? bitmap
: bitmap.copy(Bitmap.Config.ARGB_8888, true);
Canvas canvas = new Canvas(mutableBitmap);
int colour = (opacity & 0xFF) << 24;
canvas.drawColor(colour, PorterDuff.Mode.DST_IN);
return mutableBitmap;
}
代码示例来源:origin: stackoverflow.com
public static void zeroOutBitmapData(Bitmap mutableBitmap) {
if (mutableBitmap.isMutable()) {
mutableBitmap.eraseColor(android.graphics.Color.TRANSPARENT);
} else {
logger.error("Expected bitmap to be mutable");
}
}
代码示例来源:origin: posm/OpenMapKitAndroid
public synchronized boolean isBitmapMutable() {
Bitmap bitmap = getBitmap();
return null != bitmap && bitmap.isMutable();
}
代码示例来源:origin: org.arakhne.afc.ui/vector-android
@Override
protected Image makeTransparentImage(Image imageObject, float transparency) {
if (imageObject==null) return null;
Bitmap aImg = toNativeUIObject(Bitmap.class, imageObject);
Bitmap mutableBitmap = aImg.isMutable() ?
aImg : aImg.copy(Bitmap.Config.ARGB_8888, true);
Canvas canvas = new Canvas(mutableBitmap);
float t = 255f*(transparency+1f)/2f;
int colour = ((int)t & 0xFF) << 24;
canvas.drawColor(colour, PorterDuff.Mode.DST_OUT);
return new AndroidImage(mutableBitmap);
}
代码示例来源:origin: com.squareup.assertj/assertj-android
public BitmapAssert isNotMutable() {
isNotNull();
assertThat(actual.isMutable()) //
.overridingErrorMessage("Expected to not be mutable but was mutable.") //
.isFalse();
return this;
}
代码示例来源:origin: com.squareup.assertj/assertj-android
public BitmapAssert isMutable() {
isNotNull();
assertThat(actual.isMutable()) //
.overridingErrorMessage("Expected to be mutable but was not mutable.") //
.isTrue();
return this;
}
代码示例来源:origin: fookwood/Launcher3
@Thunk void addReusableBitmap(TileSource src) {
synchronized (mReusableBitmaps) {
if (Utilities.ATLEAST_KITKAT && src instanceof BitmapRegionTileSource) {
Bitmap preview = ((BitmapRegionTileSource) src).getBitmap();
if (preview != null && preview.isMutable()) {
mReusableBitmaps.add(preview);
}
}
}
}
代码示例来源:origin: Catrobat/Paintroid
@Test
public void testImageUnchangedAfterHelpAbort() {
onDrawingSurfaceView()
.perform(touchAt(DrawingSurfaceLocationProvider.MIDDLE));
Bitmap imageBefore = PaintroidApplication.layerModel.getCurrentLayer().getBitmap();
imageBefore = imageBefore.copy(imageBefore.getConfig(), imageBefore.isMutable());
onNavigationDrawer()
.performOpen();
onView(withText(R.string.help_title)).perform(click());
intended(hasComponent(hasClassName(WelcomeActivity.class.getName())));
pressBack();
Bitmap imageAfter = PaintroidApplication.layerModel.getCurrentLayer().getBitmap();
assertTrue("Image should not have changed", imageBefore.sameAs(imageAfter));
}
内容来源于网络,如有侵权,请联系作者删除!