10-16-2011 12:10 AM - edited 10-16-2011 12:11 AM
when creating Bitmap from svg file I see that gradient colors are missed. Please find below code snippet:
SVGImage svgImage = SVGImage.createImage(inputStream, null); svgImage.setViewportWidth(image.width); svgImage.setViewportHeight(image.height); SVGSVGElement svgElement = (SVGSVGElement)svgImage.getDocument().getDocumentE
lement(); svgElement.setFloatTrait("width", svgImage.getViewportWidth()); svgElement.setFloatTrait("height", svgImage.getViewportHeight()); Bitmap bitmap = new Bitmap(image.width, image.height); bitmap.setARGB(new int[image.width * image.height], 0, image.width, 0, 0, image.width,image.height); Graphics graphics = Graphics.create(bitmap); ScalableGraphics scalableGraphics = ScalableGraphics.createInstance(); scalableGraphics.bindTarget(graphics); scalableGraphics.setRenderingQuality(ScalableGraph ics.RENDERING_QUALITY_HIGH); scalableGraphics.render(padding.left, padding.top, svgImage); scalableGraphics.releaseTarget(); // now bitmap is ready.
any thoughts would be very appreciated!
10-16-2011 03:26 PM
10-16-2011 04:31 PM - edited 10-16-2011 04:32 PM
The SVG rendered directly may be handled differently than the Bitmap. I know in the past we've had issues with gradients on Bitmaps not being smooth (they appeared banded/blocky). How great is the color different between the gradient edges? If the colors are not that different, try using something like black to white or red to green, and see what it does.
10-16-2011 05:35 PM
10-16-2011 05:45 PM
The devices support (or used to only support) a specific color space. At the time we were using transparent PNG images with the gradient when we saw the issue. I think we converted all the images to the required color space and it mostly fixed the issue... but I don't recall it ever being perfect. Gradients on BlackBerry has always been a sore subject.
10-17-2011 12:00 AM