10-16-2011 12:10 AM - edited 10-16-2011 12:11 AM
Folks,
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().getDocumentElement(); 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 07:44 AM
This might be a device issue. Review this Thread for further information. I think that OS 7.0 devices all have 32 bit color screens so this problem might be historical now.
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.
http://www.blackberrydev.net/wiki/Profiling_and_Op
10-16-2011 06:04 PM
10-16-2011 08:14 PM
Sorry, didn't realise I had not pasted in my link. Here it is now....:
http://supportforums.blackberry.com/t5/Java-Develo
10-17-2011 12:00 AM
10-17-2011 12:39 PM