use of android.graphics.Bitmap_Delegate.BitmapCreateFlags in project android_frameworks_base by crdroidandroid.
the class BitmapFactory_Delegate method nativeDecodeStream.
// ------ Native Delegates ------
@LayoutlibDelegate
static /*package*/
Bitmap nativeDecodeStream(InputStream is, byte[] storage, @Nullable Rect padding, @Nullable Options opts) {
Bitmap bm = null;
Density density = Density.MEDIUM;
Set<BitmapCreateFlags> bitmapCreateFlags = EnumSet.of(BitmapCreateFlags.MUTABLE);
if (opts != null) {
density = Density.getEnum(opts.inDensity);
if (opts.inPremultiplied) {
bitmapCreateFlags.add(BitmapCreateFlags.PREMULTIPLIED);
}
opts.inScaled = false;
}
try {
if (is instanceof NinePatchInputStream) {
NinePatchInputStream npis = (NinePatchInputStream) is;
npis.disableFakeMarkSupport();
// load the bitmap as a nine patch
com.android.ninepatch.NinePatch ninePatch = com.android.ninepatch.NinePatch.load(npis, true, /*is9Patch*/
false);
// get the bitmap and chunk objects.
bm = Bitmap_Delegate.createBitmap(ninePatch.getImage(), bitmapCreateFlags, density);
NinePatchChunk chunk = ninePatch.getChunk();
// put the chunk in the bitmap
bm.setNinePatchChunk(NinePatch_Delegate.serialize(chunk));
if (padding != null) {
// read the padding
int[] paddingArray = chunk.getPadding();
padding.left = paddingArray[0];
padding.top = paddingArray[1];
padding.right = paddingArray[2];
padding.bottom = paddingArray[3];
}
} else {
// load the bitmap directly.
bm = Bitmap_Delegate.createBitmap(is, bitmapCreateFlags, density);
}
} catch (IOException e) {
Bridge.getLog().error(null, "Failed to load image", e, null);
}
return bm;
}
use of android.graphics.Bitmap_Delegate.BitmapCreateFlags in project platform_frameworks_base by android.
the class BitmapFactory_Delegate method nativeDecodeStream.
// ------ Native Delegates ------
@LayoutlibDelegate
static /*package*/
Bitmap nativeDecodeStream(InputStream is, byte[] storage, @Nullable Rect padding, @Nullable Options opts) {
Bitmap bm = null;
Density density = Density.MEDIUM;
Set<BitmapCreateFlags> bitmapCreateFlags = EnumSet.of(BitmapCreateFlags.MUTABLE);
if (opts != null) {
density = Density.getEnum(opts.inDensity);
if (opts.inPremultiplied) {
bitmapCreateFlags.add(BitmapCreateFlags.PREMULTIPLIED);
}
opts.inScaled = false;
}
try {
if (is instanceof NinePatchInputStream) {
NinePatchInputStream npis = (NinePatchInputStream) is;
npis.disableFakeMarkSupport();
// load the bitmap as a nine patch
com.android.ninepatch.NinePatch ninePatch = com.android.ninepatch.NinePatch.load(npis, true, /*is9Patch*/
false);
// get the bitmap and chunk objects.
bm = Bitmap_Delegate.createBitmap(ninePatch.getImage(), bitmapCreateFlags, density);
NinePatchChunk chunk = ninePatch.getChunk();
// put the chunk in the bitmap
bm.setNinePatchChunk(NinePatch_Delegate.serialize(chunk));
if (padding != null) {
// read the padding
int[] paddingArray = chunk.getPadding();
padding.left = paddingArray[0];
padding.top = paddingArray[1];
padding.right = paddingArray[2];
padding.bottom = paddingArray[3];
}
} else {
// load the bitmap directly.
bm = Bitmap_Delegate.createBitmap(is, bitmapCreateFlags, density);
}
} catch (IOException e) {
Bridge.getLog().error(null, "Failed to load image", e, null);
}
return bm;
}
use of android.graphics.Bitmap_Delegate.BitmapCreateFlags in project android_frameworks_base by DirtyUnicorns.
the class BitmapFactory_Delegate method nativeDecodeStream.
// ------ Native Delegates ------
@LayoutlibDelegate
static /*package*/
Bitmap nativeDecodeStream(InputStream is, byte[] storage, @Nullable Rect padding, @Nullable Options opts) {
Bitmap bm = null;
Density density = Density.MEDIUM;
Set<BitmapCreateFlags> bitmapCreateFlags = EnumSet.of(BitmapCreateFlags.MUTABLE);
if (opts != null) {
density = Density.getEnum(opts.inDensity);
if (opts.inPremultiplied) {
bitmapCreateFlags.add(BitmapCreateFlags.PREMULTIPLIED);
}
opts.inScaled = false;
}
try {
if (is instanceof NinePatchInputStream) {
NinePatchInputStream npis = (NinePatchInputStream) is;
npis.disableFakeMarkSupport();
// load the bitmap as a nine patch
com.android.ninepatch.NinePatch ninePatch = com.android.ninepatch.NinePatch.load(npis, true, /*is9Patch*/
false);
// get the bitmap and chunk objects.
bm = Bitmap_Delegate.createBitmap(ninePatch.getImage(), bitmapCreateFlags, density);
NinePatchChunk chunk = ninePatch.getChunk();
// put the chunk in the bitmap
bm.setNinePatchChunk(NinePatch_Delegate.serialize(chunk));
if (padding != null) {
// read the padding
int[] paddingArray = chunk.getPadding();
padding.left = paddingArray[0];
padding.top = paddingArray[1];
padding.right = paddingArray[2];
padding.bottom = paddingArray[3];
}
} else {
// load the bitmap directly.
bm = Bitmap_Delegate.createBitmap(is, bitmapCreateFlags, density);
}
} catch (IOException e) {
Bridge.getLog().error(null, "Failed to load image", e, null);
}
return bm;
}
use of android.graphics.Bitmap_Delegate.BitmapCreateFlags in project android_frameworks_base by ResurrectionRemix.
the class BitmapFactory_Delegate method nativeDecodeStream.
// ------ Native Delegates ------
@LayoutlibDelegate
static /*package*/
Bitmap nativeDecodeStream(InputStream is, byte[] storage, @Nullable Rect padding, @Nullable Options opts) {
Bitmap bm = null;
Density density = Density.MEDIUM;
Set<BitmapCreateFlags> bitmapCreateFlags = EnumSet.of(BitmapCreateFlags.MUTABLE);
if (opts != null) {
density = Density.getEnum(opts.inDensity);
if (opts.inPremultiplied) {
bitmapCreateFlags.add(BitmapCreateFlags.PREMULTIPLIED);
}
opts.inScaled = false;
}
try {
if (is instanceof NinePatchInputStream) {
NinePatchInputStream npis = (NinePatchInputStream) is;
npis.disableFakeMarkSupport();
// load the bitmap as a nine patch
com.android.ninepatch.NinePatch ninePatch = com.android.ninepatch.NinePatch.load(npis, true, /*is9Patch*/
false);
// get the bitmap and chunk objects.
bm = Bitmap_Delegate.createBitmap(ninePatch.getImage(), bitmapCreateFlags, density);
NinePatchChunk chunk = ninePatch.getChunk();
// put the chunk in the bitmap
bm.setNinePatchChunk(NinePatch_Delegate.serialize(chunk));
if (padding != null) {
// read the padding
int[] paddingArray = chunk.getPadding();
padding.left = paddingArray[0];
padding.top = paddingArray[1];
padding.right = paddingArray[2];
padding.bottom = paddingArray[3];
}
} else {
// load the bitmap directly.
bm = Bitmap_Delegate.createBitmap(is, bitmapCreateFlags, density);
}
} catch (IOException e) {
Bridge.getLog().error(null, "Failed to load image", e, null);
}
return bm;
}
Aggregations