public static Bitmap create(String name, BitmapFactory.Options options) { return create(name, options, null); }
@Test public void decodeFileEtc_shouldSetOptionsOutWidthAndOutHeightFromHints() { ShadowBitmapFactory.provideWidthAndHeightHints("/some/file.jpg", 123, 456); BitmapFactory.Options options = new BitmapFactory.Options(); BitmapFactory.decodeFile("/some/file.jpg", options); assertEquals(123, options.outWidth); assertEquals(456, options.outHeight); }
@Implementation protected static Bitmap decodeByteArray(byte[] data, int offset, int length) { Bitmap bitmap = decodeByteArray(data, offset, length, new BitmapFactory.Options()); ShadowBitmap shadowBitmap = Shadow.extract(bitmap); shadowBitmap.createdFromBytes = data; return bitmap; }
@Test public void createShouldSetSizeToValueFromMapAsFirstPriority() { ShadowBitmapFactory.provideWidthAndHeightHints("image.png", 111, 222); final Bitmap bitmap = ShadowBitmapFactory.create("file:image.png", null, new Point(50, 60)); assertThat(bitmap.getWidth()).isEqualTo(111); assertThat(bitmap.getHeight()).isEqualTo(222); }
String optionsString = stringify(options); if (!optionsString.isEmpty()) { shadowBitmap.appendDescription(" with options "); Point p = new Point(selectWidthAndHeight(name, widthAndHeight)); if (options != null && options.inSampleSize > 1) { p.x = p.x / options.inSampleSize;
@Implementation protected static Bitmap decodeFile(String pathName) { return decodeFile(pathName, null); }
@Implementation protected static Bitmap decodeStream(InputStream is) { return decodeStream(is, null, null); }
ShadowBackupManager.reset(); ShadowBinder.reset(); ShadowBitmapFactory.reset(); ShadowBuild.reset(); ShadowChoreographer.reset();
@Implementation public static Bitmap decodeStream(InputStream is, Rect outPadding, BitmapFactory.Options opts) { String name = is instanceof NamedStream ? is.toString().replace("stream for ", "") : null; Point imageSize = is instanceof NamedStream ? null : getImageSizeFromStream(is); Bitmap bitmap = create(name, opts, imageSize); ShadowBitmap shadowBitmap = Shadows.shadowOf(bitmap); shadowBitmap.createdFromStream = is; return bitmap; }
@Implementation public static Bitmap decodeResource(Resources res, int id) { return decodeResource(res, id, null); }
String optionsString = stringify(options); if (!optionsString.isEmpty()) { shadowBitmap.appendDescription(" with options "); Point p = new Point(selectWidthAndHeight(name, widthAndHeight)); if (options != null && options.inSampleSize > 1) { p.x = p.x / options.inSampleSize;
@Implementation protected static Bitmap decodeFile(String pathName) { return decodeFile(pathName, null); }
@Implementation public static Bitmap decodeStream(InputStream is) { return decodeStream(is, null, null); }
public void reset() { ShadowAccountManager.reset(); ShadowAudioEffect.reset(); ShadowBackgroundThread.reset(); ShadowBinder.reset(); ShadowBitmapFactory.reset(); ShadowChoreographer.reset(); ShadowContentResolver.reset(); ShadowCookieManager.resetCookies(); ShadowDialog.reset(); ShadowDrawable.clearCorruptStreamSources(); ShadowEnvironment.reset(); ShadowLog.reset(); ShadowLooper.resetThreadLoopers(); ShadowMediaMetadataRetriever.reset(); ShadowMediaPlayer.resetStaticState(); ShadowMessage.reset(); ShadowMimeTypeMap.reset(); ShadowPendingIntent.reset(); ShadowPowerManager.reset(); ShadowProcess.reset(); ShadowRenderNodeAnimator.reset(); ShadowResourceManager.reset(); ShadowResources.reset(); ShadowSQLiteConnection.reset(); ShadowStatFs.reset(); ShadowTypeface.reset(); ShadowValueAnimator.reset(); }
@Implementation public static Bitmap decodeResource(Resources res, int id) { return decodeResource(res, id, null); }
static Bitmap create(String name) { return create(name, null); }
String optionsString = stringify(options); if (!optionsString.isEmpty()) { shadowBitmap.appendDescription(" with options "); Point p = new Point(selectWidthAndHeight(name, widthAndHeight)); if (options != null && options.inSampleSize > 1) { p.x = p.x / options.inSampleSize;
@Test public void decodeByteArray_shouldIncludeOffsets() { String data = "arbitrary bytes"; ShadowBitmapFactory.provideWidthAndHeightHints(Uri.parse(data), 123, 456); byte[] bytes = data.getBytes(UTF_8); Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 1, bytes.length - 2); assertEquals("Bitmap for " + data + " bytes 1..13", shadowOf(bitmap).getDescription()); }
@Implementation public static Bitmap decodeByteArray(byte[] data, int offset, int length) { Bitmap bitmap = decodeByteArray(data, offset, length, new BitmapFactory.Options()); ShadowBitmap shadowBitmap = Shadows.shadowOf(bitmap); shadowBitmap.createdFromBytes = data; return bitmap; }
@Implementation public static Bitmap decodeFile(String pathName) { return decodeFile(pathName, null); }