本文整理汇总了Java中com.caverock.androidsvg.SVGParseException类的典型用法代码示例。如果您正苦于以下问题:Java SVGParseException类的具体用法?Java SVGParseException怎么用?Java SVGParseException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SVGParseException类属于com.caverock.androidsvg包,在下文中一共展示了SVGParseException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSvg
import com.caverock.androidsvg.SVGParseException; //导入依赖的package包/类
private void setSvg(String svgData)
{
svg = null;
try
{
svg = SVG.getFromString(svgData);
originalWidth = (int) svg.getDocumentWidth();
originalHeight = (int) svg.getDocumentHeight();
svg.setDocumentWidth("100%");
svg.setDocumentHeight("100%");
svg.setDocumentViewBox(0, 0, originalWidth, originalHeight);
}
catch (SVGParseException e)
{
// nothing to do
}
if (svg != null)
{
this.svgData = svgData;
}
imageType = this.svg == null ? ImageType.NONE : ImageType.SVG;
}
示例2: doInBackground
import com.caverock.androidsvg.SVGParseException; //导入依赖的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;
}
示例3: VectorDrawable
import com.caverock.androidsvg.SVGParseException; //导入依赖的package包/类
public VectorDrawable(Resources res, int resId) {
if (resId == 0)
return;
try {
SVG svg = cache.get(resId);
if (svg == null) {
svg = SVG.getFromResource(res, resId);
cache.put(resId, svg);
}
float density = res.getDisplayMetrics().density;
float width = svg.getDocumentViewBox().width();
float height = svg.getDocumentViewBox().height();
int intWidth = (int) (width * density);
int intHeight = (int) (height * density);
state = new VectorState(svg, intWidth, intHeight);
setBounds(0, 0, state.intWidth, state.intHeight);
} catch (SVGParseException e) {
}
}
示例4: getBitmapFromSvgInputstream
import com.caverock.androidsvg.SVGParseException; //导入依赖的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;
}
示例5: decode
import com.caverock.androidsvg.SVGParseException; //导入依赖的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);
}
}
示例6: decode
import com.caverock.androidsvg.SVGParseException; //导入依赖的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);
}
}
示例7: decode
import com.caverock.androidsvg.SVGParseException; //导入依赖的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;
}
示例8: load
import com.caverock.androidsvg.SVGParseException; //导入依赖的package包/类
/**
* Loading the svg from the resources.
*
* @param context Context object to get the resources.
* @param svgResource int resource id of the svg.
*/
public void load(Context context, int svgResource) {
if (mSvg != null) return;
try {
mSvg = SVG.getFromResource(context, svgResource);
mSvg.setDocumentPreserveAspectRatio(PreserveAspectRatio.UNSCALED);
} catch (SVGParseException e) {
Log.e(LOG_TAG, "Could not load specified SVG resource", e);
}
}
示例9: loadSvg
import com.caverock.androidsvg.SVGParseException; //导入依赖的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);
}
示例10: decode
import com.caverock.androidsvg.SVGParseException; //导入依赖的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);
}
}
示例11: loadFlag
import com.caverock.androidsvg.SVGParseException; //导入依赖的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;
}
示例12: decode
import com.caverock.androidsvg.SVGParseException; //导入依赖的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 );
}
}
示例13: decode
import com.caverock.androidsvg.SVGParseException; //导入依赖的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 );
}
}
示例14: decode
import com.caverock.androidsvg.SVGParseException; //导入依赖的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);
}
}
示例15: load
import com.caverock.androidsvg.SVGParseException; //导入依赖的package包/类
/**
* Loading the svg from the resources.
*
* @param context Context object to get the resources.
* @param svgResource int resource id of the svg.
*/
public void load(Context context, int svgResource) {
if (mSvg != null)
return;
try {
mSvg = SVG.getFromResource(context, svgResource);
mSvg.setDocumentPreserveAspectRatio(PreserveAspectRatio.UNSCALED);
} catch (SVGParseException e) {
Log.e(LOG_TAG, "Could not load specified SVG resource", e);
}
}