com.larvalabs.svgandroid.SVG Java Examples
The following examples show how to use
com.larvalabs.svgandroid.SVG.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AsyncExporter.java From Android-Material-Icons with Apache License 2.0 | 6 votes |
private Bitmap getBitmapSvg(Params params, String fileName, int densityIndex) { try { FileInputStream inputStream = new FileInputStream(mContext.getFilesDir() + MainActivity.ICONS_PATH + fileName); SVG svg = SVGParser.getSVGFromInputStream(inputStream); // Icon size relative to current processed density int fSize = ICONS_SIZE[densityIndex]; Bitmap bitmap = Bitmap.createBitmap(fSize, fSize, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); canvas.drawPicture(svg.getPicture(), new Rect(0, 0, fSize, fSize)); Bitmap finalBitmap = createTintedBitmap(bitmap, params.desiredColor); bitmap.recycle(); return finalBitmap; } catch (IOException | SVGParseException e) { e.printStackTrace(); return null; } }
Example #2
Source File: SvgAndroidSampleActivity.java From android-opensource-library-56 with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_svg_android_sample); mMatrix = new Matrix(); mImageView = (ImageView) findViewById(R.id.image); checkLayer(mImageView); SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.cute_fox); mImageView.setImageDrawable(svg.createPictureDrawable()); mImageView.setImageMatrix(mMatrix); final ScaleGestureDetector detector = new ScaleGestureDetector(this, this); mImageView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return detector.onTouchEvent(event); } }); }
Example #3
Source File: SVGView.java From Android-Material-Icons with Apache License 2.0 | 5 votes |
@Override protected SVG doInBackground(String... params) { try { FileInputStream inputStream = new FileInputStream(params[0]); SVG svg = SVGParser.getSVGFromInputStream(inputStream, Color.BLACK, Color.DKGRAY); inputStream.close(); return svg; } catch (IOException | SVGParseException e) { Log.e("SVG", params[0]); e.printStackTrace(); return null; } }
Example #4
Source File: Utils.java From Android-Material-Icons with Apache License 2.0 | 5 votes |
public static Drawable getDrawableForSvg(Context context, String fileName) { try { FileInputStream inputStream = new FileInputStream(context.getFilesDir() + MainActivity.ICONS_PATH + fileName); SVG svg = SVGParser.getSVGFromInputStream(inputStream, Color.BLACK, Color.DKGRAY); return svg.createPictureDrawable(); } catch (IOException | SVGParseException e) { e.printStackTrace(); return null; } }
Example #5
Source File: SVGView.java From Android-Material-Icons with Apache License 2.0 | 4 votes |
@Override protected void onPostExecute(SVG svg) { super.onPostExecute(svg); setImageDrawable(svg == null ? null : svg.createPictureDrawable()); }