本文整理匯總了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;
}