本文整理汇总了Java中com.caverock.androidsvg.SVG.renderToCanvas方法的典型用法代码示例。如果您正苦于以下问题:Java SVG.renderToCanvas方法的具体用法?Java SVG.renderToCanvas怎么用?Java SVG.renderToCanvas使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.caverock.androidsvg.SVG
的用法示例。
在下文中一共展示了SVG.renderToCanvas方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doInBackground
import com.caverock.androidsvg.SVG; //导入方法依赖的package包/类
private Bitmap doInBackground(Integer... paramVarArgs)
{
try
{
SVG localSVG = SVG.getFromResource(this.mContext, paramVarArgs[0].intValue());
Bitmap localBitmap = Bitmap.createBitmap(this.mWidth, this.mHeight, Bitmap.Config.ARGB_8888);
localSVG.renderToCanvas(new Canvas(localBitmap));
return localBitmap;
}
catch (SVGParseException localSVGParseException)
{
Object[] arrayOfObject = new Object[2];
arrayOfObject[0] = paramVarArgs[0];
arrayOfObject[1] = localSVGParseException.getMessage();
FinskyLog.e("Error loading SVG resource 0x%x: %s", arrayOfObject);
}
return null;
}
示例2: getBitmapFromSvgInputstream
import com.caverock.androidsvg.SVG; //导入方法依赖的package包/类
private Bitmap getBitmapFromSvgInputstream(InputStream is) {
Bitmap bitmap = null;
try {
SVG svg = SVG.getFromInputStream(is);
double width = 16;
double height = 16;
if (svg.getDocumentViewBox() != null) {
width = svg.getDocumentViewBox().width();
height = svg.getDocumentViewBox().height();
} else {
Log.d(TAG, "DocumentViewBox is null. assuming width and heigh of 16px.");
}
bitmap = Bitmap.createBitmap((int) Math.ceil(width), (int) Math.ceil(height), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);//drawARGB(0,0,0,0);//drawRGB(255, 255, 255);
svg.renderToCanvas(canvas);
} catch (SVGParseException e) {
e.printStackTrace();
}
return bitmap;
}
示例3: loadFlag
import com.caverock.androidsvg.SVG; //导入方法依赖的package包/类
@Override
public boolean loadFlag(View view, int imageViewId, String langId) {
ImageView imageView = (ImageView) view.findViewById(imageViewId);
// read a flag from the assets folder
SVG svg = null;
try {
svg = SVG.getFromAsset(MyApp.getAppContext().getAssets(), "flags/" + langId + ".svg");
} catch (SVGParseException | IOException e) {
return false;
}
// create a canvas to draw onto
if (svg.getDocumentWidth() != -1) {
Bitmap bitmap = Bitmap.createBitmap((int) Math.ceil(svg.getDocumentWidth()),
(int) Math.ceil(svg.getDocumentHeight()),
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
// clear background to white
canvas.drawRGB(255, 255, 255);
// render the flag onto our canvas
svg.renderToCanvas(canvas);
// draw flag on imageView
imageView.setImageBitmap(bitmap);
}
return true;
}
示例4: decode
import com.caverock.androidsvg.SVG; //导入方法依赖的package包/类
public Resource<Bitmap> decode (InputStream source, int width, int height) throws IOException
{
try
{
SVG svg = SVG.getFromInputStream( source );
Bitmap bitmap = findBitmap( width, height );
Canvas canvas = new Canvas( bitmap );
svg.renderToCanvas( canvas );
return BitmapResource.obtain( bitmap, bitmapPool );
} catch ( SVGParseException ex )
{
throw new IOException( "Cannot load SVG from stream", ex );
}
}
示例5: writeSvgAsPng
import com.caverock.androidsvg.SVG; //导入方法依赖的package包/类
private void writeSvgAsPng(InputStream svgData, int width, int height, OutputStream output) throws SVGParseException {
SVG svg = SVG.getFromInputStream(svgData);
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.scale(width / svg.getDocumentWidth(), height / svg.getDocumentHeight(), 0F, 0F);
svg.renderToCanvas(canvas);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, output);
}