本文整理汇总了Java中com.larvalabs.svgandroid.SVGParser.getSVGFromInputStream方法的典型用法代码示例。如果您正苦于以下问题:Java SVGParser.getSVGFromInputStream方法的具体用法?Java SVGParser.getSVGFromInputStream怎么用?Java SVGParser.getSVGFromInputStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.larvalabs.svgandroid.SVGParser
的用法示例。
在下文中一共展示了SVGParser.getSVGFromInputStream方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBitmapSvg
import com.larvalabs.svgandroid.SVGParser; //导入方法依赖的package包/类
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;
}
}
示例2: doInBackground
import com.larvalabs.svgandroid.SVGParser; //导入方法依赖的package包/类
@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;
}
}
示例3: getDrawableForSvg
import com.larvalabs.svgandroid.SVGParser; //导入方法依赖的package包/类
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;
}
}
示例4: syncMapTiles
import com.larvalabs.svgandroid.SVGParser; //导入方法依赖的package包/类
/**
* Synchronise the map overlay files either from the local assets (if available) or from a remote url.
*
* @param collection Set of tiles containing a local filename and remote url.
* @throws IOException
*/
private void syncMapTiles(Collection<Tile> collection) throws IOException, SVGParseException {
//keep track of used files, unused files are removed
ArrayList<String> usedTiles = Lists.newArrayList();
for(Tile tile : collection){
final String filename = tile.filename;
final String url = tile.url;
usedTiles.add(filename);
if (!MapUtils.hasTile(mContext, filename)) {
// copy or download the tile if it is not stored yet
if (MapUtils.hasTileAsset(mContext, filename)) {
// file already exists as an asset, copy it
MapUtils.copyTileAsset(mContext, filename);
} else {
// download the file
File tileFile = MapUtils.getTileFile(mContext, filename);
BasicHttpClient httpClient = new BasicHttpClient();
httpClient.setRequestLogger(mQuietLogger);
HttpResponse httpResponse = httpClient.get(url, null);
writeFile(httpResponse.getBody(), tileFile);
// ensure the file is valid SVG
InputStream is = new FileInputStream(tileFile);
SVG svg = SVGParser.getSVGFromInputStream(is);
is.close();
}
}
}
MapUtils.removeUnusedTiles(mContext, usedTiles);
}
示例5: TileGenerator
import com.larvalabs.svgandroid.SVGParser; //导入方法依赖的package包/类
public TileGenerator() {
mBitmap = Bitmap.createBitmap(mDimension, mDimension, Bitmap.Config.ARGB_8888);
mStream = new ByteArrayOutputStream(mDimension * mDimension * 4);
mSvg = SVGParser.getSVGFromInputStream(new ByteArrayInputStream(mSvgFile));
}