Consider this SVG file which is a 100×100 image with a circle in teh top left corner:
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> <circle cx="20" cy="20" r="10"/> </svg>
If you load this into a drawable the bounds are wrong:
ScopedPointer<Drawable> ourDrawable = Drawable::createFromImageData(data, size); ourDrawable->getDrawableBounds(); // returns 10 10 20 20 ourDrawable->getBounds(); // also returns 10 10 20 20 // this appears to be the bounding box of all graphic elements in the SVG file
The expected size is 100 by 100, as specified by the viewbox (or by the width and height attributes). This messes up the alignment if you use methods like
You can get the actual size via
DrawableComposite::getContentArea, but this is annoying because it won’t work with drawables coming from an image file.
Can this be fixed somehow, or worked around? Maybe existing code relies on the current behaviour, but on the other hand, image files (especially icons) often have padding for a good reason.