当前位置: 首页>>代码示例>>Java>>正文


Java SVG.renderToCanvas方法代码示例

本文整理汇总了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;
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:19,代码来源:LoadSVGTask.java

示例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;
}
 
开发者ID:openhab,项目名称:openhab-android,代码行数:23,代码来源:MyWebImage.java

示例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;
}
 
开发者ID:feberhard,项目名称:LLAMA,代码行数:32,代码来源:LanguageService.java

示例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 );
    }
}
 
开发者ID:tecruz,项目名称:AndroidBaseApplication,代码行数:15,代码来源:SvgBitmapDecoder.java

示例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);
}
 
开发者ID:jzarnikov,项目名称:SVG-Rasterizer-Cordova-Plugin,代码行数:9,代码来源:SVGRasterizerPlugin.java


注:本文中的com.caverock.androidsvg.SVG.renderToCanvas方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。