I am trying to display svgs with uil. I wrote my own imagedecoder using androidsvg (http://code.google.com/p/androidsvg/) like this:
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());
}
}
The SVG is displayed, but following problems occurs:
1.) Colors and pictures are not rendered and displayed 2.) The rendering takes too long and the logcat shows something like this:
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
So, how can I improve the performance and solve the problems? Is there a better way to integrate svgs with uil?