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


Java SVG.getFromInputStream方法代码示例

本文整理汇总了Java中com.caverock.androidsvg.SVG.getFromInputStream方法的典型用法代码示例。如果您正苦于以下问题:Java SVG.getFromInputStream方法的具体用法?Java SVG.getFromInputStream怎么用?Java SVG.getFromInputStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.caverock.androidsvg.SVG的用法示例。


在下文中一共展示了SVG.getFromInputStream方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: decode

import com.caverock.androidsvg.SVG; //导入方法依赖的package包/类
public Resource<SVG> decode(InputStream source, int width, int height, Options options)
    throws IOException {
  try {
    SVG svg = SVG.getFromInputStream(source);
    return new SimpleResource<SVG>(svg);
  } catch (SVGParseException ex) {
    throw new IOException("Cannot load SVG from stream", ex);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:SvgDecoder.java

示例3: decode

import com.caverock.androidsvg.SVG; //导入方法依赖的package包/类
public Resource<SVG> decode(InputStream source, int width, int height, Options options)
    throws IOException {
  try {
    SVG svg = SVG.getFromInputStream(source);
    return new SimpleResource<>(svg);
  } catch (SVGParseException ex) {
    throw new IOException("Cannot load SVG from stream", ex);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:SvgDecoder.java

示例4: decode

import com.caverock.androidsvg.SVG; //导入方法依赖的package包/类
@Override
public CloseableImage decode(
    EncodedImage encodedImage,
    int length,
    QualityInfo qualityInfo,
    ImageDecodeOptions options) {
  try {
    SVG svg = SVG.getFromInputStream(encodedImage.getInputStream());
    return new CloseableSvgImage(svg);
  } catch (SVGParseException e) {
    e.printStackTrace();
  }
  return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:SvgDecoderExample.java

示例5: loadSvg

import com.caverock.androidsvg.SVG; //导入方法依赖的package包/类
private Pair<Drawable, int[]> loadSvg(InputStream is) throws SVGParseException {
    SVG svg = SVG.getFromInputStream(is);
    int[] size = new int[2];
    size[0] = (int) svg.getDocumentViewBox().width();
    size[1] = (int) svg.getDocumentViewBox().height();
    svg.setDocumentWidth(mSize);
    svg.setDocumentHeight(mSize);
    return new Pair<>(new PictureDrawable(svg.renderToPicture()), size);
}
 
开发者ID:jruesga,项目名称:rview,代码行数:10,代码来源:AsyncImageDiffProcessor.java

示例6: decode

import com.caverock.androidsvg.SVG; //导入方法依赖的package包/类
public Resource<SVG> decode(InputStream source, int width, int height) throws IOException {
    try {
        SVG svg = SVG.getFromInputStream(source);
        return new SimpleResource<SVG>(svg);
    } catch (SVGParseException ex) {
        throw new IOException("Cannot load SVG from stream", ex);
    }
}
 
开发者ID:amrendra18,项目名称:udacity-p3,代码行数:9,代码来源:SvgDecoder.java

示例7: decode

import com.caverock.androidsvg.SVG; //导入方法依赖的package包/类
@Override
public Resource<SVG> decode (InputStream source, int width, int height) throws IOException
{
    try
    {
        SVG svg = SVG.getFromInputStream( source );
        return new SimpleResource<SVG>( svg );
    } catch ( SVGParseException ex )
    {
        throw new IOException( "Cannot load SVG from stream", ex );
    }
}
 
开发者ID:tecruz,项目名称:AndroidBaseApplication,代码行数:13,代码来源:SvgDecoder.java

示例8: 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

示例9: getAndroidBitmap

import com.caverock.androidsvg.SVG; //导入方法依赖的package包/类
private static android.graphics.Bitmap getAndroidBitmap(InputStream inputStream, PlatformConnector.SvgScaleType scaleType, float scaleValue) throws IOException {
    synchronized (SVG.getVersion()) {
        try {
            SVG svg = SVG.getFromInputStream(inputStream);
            Picture picture = svg.renderToPicture();

            float scale = 1;

            switch (scaleType) {

                case SCALED_TO_WIDTH:
                    scale = scaleValue / picture.getWidth();
                    break;
                case SCALED_TO_HEIGHT:
                    scale = scaleValue / picture.getHeight();
                    break;
                case DPI_SCALED:
                    scale = CB.getScaledFloat(scaleValue);
                    break;
                case SCALED_TO_WIDTH_OR_HEIGHT:
                    scale = Math.min(scaleValue / picture.getHeight(), scaleValue / picture.getWidth());
                    break;
            }

            float bitmapWidth = picture.getWidth() * scale;
            float bitmapHeight = picture.getHeight() * scale;

            android.graphics.Bitmap bitmap = android.graphics.Bitmap.createBitmap((int) Math.ceil(bitmapWidth),
                    (int) Math.ceil(bitmapHeight), Bitmap.Config.ARGB_8888);
            Canvas canvas = new Canvas(bitmap);
            canvas.drawPicture(picture, new RectF(0, 0, bitmapWidth, bitmapHeight));

            return bitmap;
        } catch (Exception e) {
            throw new IOException(e);
        }
    }
}
 
开发者ID:Longri,项目名称:cachebox3.0,代码行数:39,代码来源:AndroidRealSvgBitmap.java

示例10: decode

import com.caverock.androidsvg.SVG; //导入方法依赖的package包/类
@Override
public Resource<SVG> decode(InputStream source, int width, int height) throws IOException {
    try {
        SVG svg = SVG.getFromInputStream(source);
        svg.setDocumentHeight(height);
        svg.setDocumentWidth(width);
        svg.setDocumentPreserveAspectRatio(PreserveAspectRatio.LETTERBOX);
        return new SimpleResource<>(svg);
    } catch (SVGParseException ex) {
        throw new IOException("Cannot load SVG from stream", ex);
    }
}
 
开发者ID:StepicOrg,项目名称:stepik-android,代码行数:13,代码来源:SvgDecoder.java

示例11: decode

import com.caverock.androidsvg.SVG; //导入方法依赖的package包/类
public Resource<SVG> decode(InputStream source, int width, int height) throws IOException {
    try {
        SVG svg = SVG.getFromInputStream(source);
        return new SimpleResource<>(svg);
    } catch (SVGParseException ex) {
        throw new IOException("Cannot load SVG from stream", ex);
    }
}
 
开发者ID:xamoom,项目名称:xamoom-android-sdk,代码行数:9,代码来源:SvgDecoder.java

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