我想,以显示与UIL svgs。 我写了使用androidsvg(我自己imagedecoder http://code.google.com/p/androidsvg/ )是这样的:
public class SVGImageDecoder implements ImageDecoder {
@Override
public Bitmap decode(ImageDecodingInfo imageDecodingInfo) throws IOException {
Bitmap decodedBitmap = null;
InputStream inputStream = getImageStream(imageDecodingInfo);
SVG svg = null;
try {
svg = SVG.getFromInputStream(inputStream);
} catch (SVGParseException e) {
e.printStackTrace();
}
Picture picture = svg.renderToPicture();
PictureDrawable pictureDrawable = new PictureDrawable(picture);
decodedBitmap = Bitmap.createBitmap(pictureDrawable.getIntrinsicWidth(),
pictureDrawable.getIntrinsicHeight(), Bitmap.Config.RGB_565);
Canvas canvas = new Canvas(decodedBitmap);
// Clear background to white
canvas.drawRGB(255, 255, 255);
svg.renderToCanvas(canvas);
return decodedBitmap;
}
protected InputStream getImageStream(ImageDecodingInfo decodingInfo) throws IOException {
return decodingInfo.getDownloader().getStream(decodingInfo.getImageUri(), decodingInfo.getExtraForDownloader());
}
}
显示SVG,但是会出现以下问题:
1)颜色和图片不渲染和显示2)渲染耗时过长和logcat的说明是这样的:
01-06 23:48:15.310 15505-15506/de.phcom.epaper2 D/dalvikvm﹕ GC_CONCURRENT freed 2048K, 10% free 26540K/29187K, paused 1ms+29ms 01-06 23:48:15.645 15505-15506/de.phcom.epaper2 D/dalvikvm﹕ GC_CONCURRENT freed 2046K, 10% free 26541K/29187K, paused 2ms+27ms 01-06 23:48:15.970 15505-15506/de.phcom.epaper2 D/dalvikvm﹕ GC_CONCURRENT freed 2047K, 10% free 26542K/29187K, paused 1ms+28ms 01-06 23:48:16.305 15505-15506/de.phcom.epaper2 D/dalvikvm﹕ GC_CONCURRENT freed 2049K, 10% free 26541K/29187K, paused 2ms+29ms 01-06 23:48:16.650 15505-15506/de.phcom.epaper2 D/dalvikvm﹕ GC_CONCURRENT freed 2051K, 10% free 26538K/29187K, paused 1ms+27ms
所以,我怎么能提高性能,并解决这些问题? 是否有svgs与UIL整合更好的办法?