本文整理汇总了Java中android.graphics.Canvas.drawPicture方法的典型用法代码示例。如果您正苦于以下问题:Java Canvas.drawPicture方法的具体用法?Java Canvas.drawPicture怎么用?Java Canvas.drawPicture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Canvas
的用法示例。
在下文中一共展示了Canvas.drawPicture方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBitmap
import android.graphics.Canvas; //导入方法依赖的package包/类
public static Bitmap createBitmap(InputStream in, int w, int h, boolean closeStream) {
if (in == null) {
return null;
}
com.larvalabs.svgandroid.SVG svg;
svg = new SVGBuilder().readFromInputStream(in).build();
Bitmap bitmap = Bitmap.createBitmap(w, h, Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Picture pic = svg.getPicture();
// svg.renderToCanvas(canvas/*, new RectF(0f, 0f, (float)w, (float)h)*/);
// svg.renderToCanvas(canvas, new RectF(0f, 0f, (float)w, (float)h));
canvas.drawPicture(pic, new Rect(0, 0, w, h));
if (closeStream) {
try {
in.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return bitmap;
}
示例2: draw
import android.graphics.Canvas; //导入方法依赖的package包/类
/**
* Original author nimingtao wrote that this method may not work on devices with Ice Cream Sandwich (Android v4.0).<br/>
* See: http://stackoverflow.com/q/10384613/1084488<br/>
* Apparently this is because canvas.drawPicture is not supported with hardware acceleration. If the problem occurs
* and solved by programmatically turning off hardware acceleration only on the view that will draw the Picture:
* view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);<br/>
* <br/>
* However, I (mstevens83) was unable to reproduce this problem on an emulator running Ice Cream Sandwich, nor on
* physical devices running Jelly Bean (v4.1.2 and v4.3 tested).
*/
@Override
public void draw(Canvas canvas) {
if (getPicture() != null) {
Rect bounds = getBounds();
canvas.save();
// draw picture to fit bounds!
canvas.drawPicture(getPicture(), bounds);
canvas.restore();
}
}
示例3: draw
import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public int draw(Canvas canvas) {
if (destF != null) {
canvas.drawPicture(picture, destF);
} else if (dest != null) {
canvas.drawPicture(picture, dest);
} else {
canvas.drawPicture(picture);
}
return NO_SAVE;
}