use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.
the class BitmapFactory_Delegate method nativeDecodeStream.
@LayoutlibDelegate
static /*package*/
Bitmap nativeDecodeStream(InputStream is, byte[] storage, Rect padding, Options opts, boolean applyScale, float scale) {
Bitmap bm = null;
//TODO support rescaling
Density density = Density.MEDIUM;
if (opts != null) {
density = Density.getEnum(opts.inDensity);
}
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(), true, /*isMutable*/
density);
NinePatchChunk chunk = ninePatch.getChunk();
// put the chunk in the bitmap
bm.setNinePatchChunk(NinePatch_Delegate.serialize(chunk));
// 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, true, density);
}
} catch (IOException e) {
Bridge.getLog().error(null, "Failed to load image", e, null);
}
return bm;
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.
the class Bitmap_Delegate method nativeCreate.
// ---- native methods ----
@LayoutlibDelegate
static /*package*/
Bitmap nativeCreate(int[] colors, int offset, int stride, int width, int height, int nativeConfig, boolean mutable) {
int imageType = getBufferedImageType(nativeConfig);
// create the image
BufferedImage image = new BufferedImage(width, height, imageType);
if (colors != null) {
image.setRGB(0, 0, width, height, colors, offset, stride);
}
// create a delegate with the content of the stream.
Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.nativeToConfig(nativeConfig));
return createBitmap(delegate, mutable, Bitmap.getDefaultDensity());
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.
the class Bitmap_Delegate method nativeCopy.
@LayoutlibDelegate
static /*package*/
Bitmap nativeCopy(int srcBitmap, int nativeConfig, boolean isMutable) {
Bitmap_Delegate srcBmpDelegate = sManager.getDelegate(srcBitmap);
if (srcBmpDelegate == null) {
return null;
}
BufferedImage srcImage = srcBmpDelegate.getImage();
int width = srcImage.getWidth();
int height = srcImage.getHeight();
int imageType = getBufferedImageType(nativeConfig);
// create the image
BufferedImage image = new BufferedImage(width, height, imageType);
// copy the source image into the image.
int[] argb = new int[width * height];
srcImage.getRGB(0, 0, width, height, argb, 0, width);
image.setRGB(0, 0, width, height, argb, 0, width);
// create a delegate with the content of the stream.
Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.nativeToConfig(nativeConfig));
return createBitmap(delegate, isMutable, Bitmap.getDefaultDensity());
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.
the class Paint_Delegate method nativeGetCharArrayBounds.
@LayoutlibDelegate
static /*package*/
void nativeGetCharArrayBounds(int nativePaint, char[] text, int index, int count, int bidiFlags, Rect bounds) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(nativePaint);
if (delegate == null) {
return;
}
// See MeasureText
if (delegate.mFonts.size() > 0) {
FontInfo mainInfo = delegate.mFonts.get(0);
Rectangle2D rect = mainInfo.mFont.getStringBounds(text, index, index + count, delegate.mFontContext);
bounds.set(0, 0, (int) rect.getWidth(), (int) rect.getHeight());
}
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.
the class Region_Delegate method nativeOp.
@LayoutlibDelegate
static /*package*/
boolean nativeOp(int native_dst, Rect rect, int native_region, int op) {
Region_Delegate region = sManager.getDelegate(native_dst);
if (region == null) {
return false;
}
region.mArea = combineShapes(region.mArea, new Rectangle2D.Float(rect.left, rect.top, rect.width(), rect.height()), op);
assert region.mArea != null;
if (region.mArea != null) {
region.mArea = new Area();
}
return region.mArea.getBounds().isEmpty() == false;
}
Aggregations