use of com.caverock.androidsvg.SVGParseException in project Carbon by ZieIony.
the class CheckableDrawable method renderSVGs.
private void renderSVGs() {
Rect bounds = getBounds();
if (bounds.width() <= 0 && bounds.height() <= 0)
return;
try {
{
SVG svg = SVG.getFromResource(context, checkedRes);
checkedBitmap = Bitmap.createBitmap(bounds.width(), bounds.height(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(checkedBitmap);
svg.setDocumentWidth(checkedBitmap.getWidth());
svg.setDocumentHeight(checkedBitmap.getHeight());
svg.renderToCanvas(canvas);
checkedShader = new BitmapShader(checkedBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
Matrix matrix = new Matrix();
matrix.postTranslate(bounds.left, bounds.top);
checkedShader.setLocalMatrix(matrix);
}
{
SVG svg2 = SVG.getFromResource(context, uncheckedRes);
uncheckedBitmap = Bitmap.createBitmap(bounds.width(), bounds.height(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(uncheckedBitmap);
svg2.setDocumentWidth(uncheckedBitmap.getWidth());
svg2.setDocumentHeight(uncheckedBitmap.getHeight());
svg2.renderToCanvas(canvas);
}
{
SVG svg3 = SVG.getFromResource(context, filledRes);
filledBitmap = Bitmap.createBitmap(bounds.width(), bounds.height(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(filledBitmap);
svg3.setDocumentWidth(filledBitmap.getWidth());
svg3.setDocumentHeight(filledBitmap.getHeight());
svg3.renderToCanvas(canvas);
}
maskBitmap = Bitmap.createBitmap(bounds.width(), bounds.height(), Bitmap.Config.ARGB_8888);
maskCanvas = new Canvas(maskBitmap);
radius = (float) (Math.sqrt(2) * bounds.width() / 2);
} catch (SVGParseException e) {
Log.e(CheckableDrawable.class.getSimpleName(), "There was an error parsing SVG");
} catch (NullPointerException e) {
// TODO: what is this catch for?
}
}
Aggregations