/** * 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; }
public BitmapAssert isMutable() { isNotNull(); assertThat(actual.isMutable()) // .overridingErrorMessage("Expected to be mutable but was not mutable.") // .isTrue(); return this; }
public BitmapAssert isNotMutable() { isNotNull(); assertThat(actual.isMutable()) // .overridingErrorMessage("Expected to not be mutable but was mutable.") // .isFalse(); return this; }
@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(); }
public void isImmutable() { if (actual().isMutable()) { fail("is immutable"); } }
public void isMutable() { if (!actual().isMutable()) { fail("is mutable"); } }
@Test public void shouldCreateMutableBitmap() throws Exception { Bitmap mutableBitmap = Bitmap.createBitmap(100, 200, Bitmap.Config.ARGB_8888); assertThat(mutableBitmap.isMutable()).isTrue(); }
@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); }
@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(); }
public synchronized boolean isBitmapMutable() { Bitmap bitmap = getBitmap(); return null != bitmap && bitmap.isMutable(); }
@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; }
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
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; }
public static void zeroOutBitmapData(Bitmap mutableBitmap) { if (mutableBitmap.isMutable()) { mutableBitmap.eraseColor(android.graphics.Color.TRANSPARENT); } else { logger.error("Expected bitmap to be mutable"); } }
public synchronized boolean isBitmapMutable() { Bitmap bitmap = getBitmap(); return null != bitmap && bitmap.isMutable(); }
@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); }
public BitmapAssert isNotMutable() { isNotNull(); assertThat(actual.isMutable()) // .overridingErrorMessage("Expected to not be mutable but was mutable.") // .isFalse(); return this; }
public BitmapAssert isMutable() { isNotNull(); assertThat(actual.isMutable()) // .overridingErrorMessage("Expected to be mutable but was not mutable.") // .isTrue(); return this; }
@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); } } } }
@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)); }