sonmezab / androidsvg Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/androidsvg
Automatically exported from code.google.com/p/androidsvg
Hello Paul,
This is more a suggestion than an issue. It think it would be nice if the SVG
class had an additional getFromResource() method that takes a Resources object
instead of a Context object. This would make the library a bit more flexible to
integrate in existing code (at least in my case).
Here's a patch:
https://code.google.com/r/matthiasstevens-androidsvg/source/detail?r=55dded6515d
5b1aacf4b5ccb66c6d24de0dd0b53
Could you please include this in your next release?
Best & thanks in advance,
Matthias
Original issue reported on code.google.com by [email protected]
on 22 Aug 2013 at 11:37
What steps will reproduce the problem?
SVG svg = SVG.getFromResource(this, R.raw.harley);
Picture p = svg.renderToPicture();
Drawable drawable = new PictureDrawable(p);
imageView.setImageDrawable(drawable);
What is the expected output? What do you see instead?
Image with negative coordinates in svg viewbox are truncated.
What version of the product are you using? On what operating system?
1.1.182
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 8 Jul 2013 at 10:48
Attachments:
What steps will reproduce the problem?
1. run the attached project
2.
3.
What is the expected output? What do you see instead?
I expected to see an image big as the whole screen, while I see a small image.
It seems it doesn't scale
What version of the product are you using? On what operating system?
1.1.182 on Android 2.3.6
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 25 May 2013 at 9:35
Attachments:
What steps will reproduce the problem?
1. Render the attached test.svg using renderToCanvas
What is the expected output? What do you see instead?
For a small file like this, I'd have expected a few ms to render. Instead, it
took 200ms - 300ms. Using renderToPicture, and rendering the picture it was
only 15ms.
I profiled it, and processMaskBitmaps was the major bottleneck. Instead of the
custom processing, I'd guess drawBitmap using a PorterDuffXfermode would work
here, too. E.g. paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
Original issue reported on code.google.com by [email protected]
on 17 Aug 2014 at 8:41
Attachments:
Sometime the SVG document dimensions are expressed as percentages and not
returned by getDocumentWidth/Height. Nevertheless it would be useful to know at
least the aspect ratio of the document in order to select the optimum
dimensions for a bitmap to host the SVG.
I would propose to introduce a new API like this:
public float getDocumentAspectRatio()
{
if (this.rootElement == null)
return 1.0f;
Length w = this.rootElement.width;
Length h = this.rootElement.height;
return w.value/h.value;
}
Original issue reported on code.google.com by [email protected]
on 5 Jun 2013 at 4:19
What steps will reproduce the problem?
https://code.google.com/p/androidsvg/wiki/FAQ#My_SVG_doesn't_render_if_I_try_to_
do_Canvas.drawPicture()_o
What is the expected output? What do you see instead?
Instead of the horrible reflection, please replace it with one of the following
solutions (or both).
Note how the two code blocks are simpler and shorter (even together) than the
current one.
If the project is using support-v4:
import android.support.v4.view.ViewCompat;
ViewCompat.setLayerType(view, ViewCompat.LAYER_TYPE_SOFTWARE, null);
If it's a plain android project targeting API 11+ (which is where the method
was added, not API 13):
import android.os.Build.*;
@TargetApi(VERSION_CODES.HONEYCOMB)
public static void setSoftwareLayerType(View view) {
if (VERSION_CODES.HONEYCOMB <= VERSION.SDK_INT) {
view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
} // else: no layer support, so no hardware support to disable
}
Original issue reported on code.google.com by papp.robert.s
on 7 Dec 2014 at 9:28
Hello,
In the attached SVG files I have used a <marker> to draw arrow heads.
Unfortunately AndroidSVG does not seem to be able to render these. It only
renders the line of the arrows, not the heads.
So could it be that your support for the <marker> feature is incomplete or
buggy?
The files render correctly in Firefox, Chrome and Inkscape (but not in Internet
Explorer).
I've tested this on Android v4.1.2.
Thanks in advance for looking into this.
Original issue reported on code.google.com by [email protected]
on 21 Aug 2013 at 6:27
Attachments:
First great job on such a great project. I wanted to know would it be possible
to implement a parsePath() and/or parseGroup() method so that one could pull a
single path or group from an SVG. There are other libraries that implement this
functionality but they are no where near as consistent in correctly displaying
SVG's. This would allow you grab and draw specific paths or groups from an SVG
and greatly expand what can be done with this library.
Original issue reported on code.google.com by [email protected]
on 7 Jul 2014 at 11:49
Bitmap bm = Bitmap.createBitmap((int) w, (int) h, Bitmap.Config.RGB_565);
Canvas bmcanvas = new Canvas(bm);
// Render our document scaled to fit inside our canvas dimensions
svg.renderToCanvas(bmcanvas, null, 96f, AspectRatioAlignment.xMidYMid,
AspectRatioScale.MEET);
What is the expected output? What do you see instead?
A bitmap with the rendered SVG, instead the application closes without an
exception.
What version of the product are you using? On what operating system?
Latest version
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 17 Jun 2013 at 7:35
When I try to add this library to Android Studio I follow the following method:
1. Download zip of androidsvg lib
2. Unzip
3. (From Android Studio) File -> Import Project...
4. Select the proper input folder
5. Select the proper output folder
6. Leave all settings checked as default
When the importation ends, the androidsvg package still does not appear in the
interface and no errors are reported.
Original issue reported on code.google.com by [email protected]
on 8 Apr 2014 at 10:15
The svg-android library allows you to substitute one colour for another at
parse time. Each of the parser methods have a variant that takes two extra
parameters: searchColor and replaceColor.
This feature has been requested in AndroidSVG as well.
Some additional thoughts:
1. Having just a single search and replace color seems a bit limiting.
I would imagine that having a new method:
SVG.replaceColour(searchColour, replaceColour);
that could be called multiple times to build up a colour map would be more useful. Or perhaps:
SVG.getColourMap().add(searchColour, replaceColour);
SVG.setColourMap(newColourMap);
2. Perhaps other colour transformation options like:
SVG.setColourMatrix(colourMatrix);
Would that be useful to anyone?
3. Another possibility would be adding support for SVG Parameters
(http://www.w3.org/TR/SVGParamPrimer/)
Please upvote and comment if you need, or would use, colour mapping
functionality.
Your feedback is appreciated.
Original issue reported on code.google.com by [email protected]
on 19 Jul 2013 at 9:50
What steps will reproduce the problem?
1. My app uses a number of svg images, some of them in several places. All of
them are use an asset.
What is the expected output? What do you see instead?
The app takes a performance hit. SVG images load slowly.
What version of the product are you using? On what operating system?
Version 1.2 (hg clone).
Please provide any additional information below.
My suggestion is that an "asset" attribute is defined to go along with the
standard "svg" attribute. "asset" should be set to override "svg". When
specified the SVGImageView should bypass the Resource and InternalURI logic and
load the image straight from the asset. Gains a little speed and makes the use
of the View in the layout more logical.
As far as caching is concerned, I have implemented a solution using a "cache"
(boolean) attribute and an internal HashMap which caches the Drawable with the
"svg" or "asset" attribute value as the key.
The first time a particular asset (resource or URI) is used with "cache" set to
true the drawable is created and stored in the HashMap. The next time an
SVGImageView accesses the same "asset" (again with "cache" set to true) we
simply pull the stored drawable.
This introduces a significant speed boost. Find the modified SVGImageView.java
file attached.
Original issue reported on code.google.com by [email protected]
on 6 Nov 2013 at 5:30
Attachments:
What steps will reproduce the problem?
1. Load an SVG with an image element referencing an external SVG.
2. Register external resolver using SimpleAssetResolver
3. Attempt to render SVG.
What is the expected output? What do you see instead?
I expect the image to render properly of course, but instead the external SVGs
are missing. Logcat shows "Could not locate image 'foo.svg'". External PNGs
work fine.
What version of the product are you using? On what operating system?
This is with hg e645ba264575 Tue Aug 19 06:47:41 2014 +1200.
Please provide any additional information below.
It appears that androidsvg is using BitmapFactory.decodeStream() to attempt to
parse the external image. That works fine for PNG, but of course fails for SVG.
SVG is required to be supported by the standard.
http://www.w3.org/TR/SVG/struct.html#ImageElement
I'd be inclined to change the SVGExternalFileResolver API, as it currently
returns a Bitmap, which is only appropriate for raster images.
Original issue reported on code.google.com by [email protected]
on 12 Jan 2015 at 6:37
After moving to v1.2.0 Some of the SVGs do not work correctly with
PreserveAspectRatio.
I tried the following configurations: FULLSCREEN, LETTERBOX and STRETCH, but
they all behave exactly like UNSCALED.
For the previous version I used AspectRatioAlignment and AspectRatioScale and
had no such problems.
What I do is:
1. SVG svg = SVG.getFromInputStream(inputStream); \\ Get the SVG
2. svg.setDocumentPreserveAspectRatio(ratio); \\ Select the aspect ration
3. svg.renderToCanvas(canvas); \\ Render on the canvas
It was a bit different for the old version, but it worked well. Also I have no
problem with most of my SVGs, just some. Actually I have problem with simpler
ones.
I will attach the simplest SVG I have the problem with.
Original issue reported on code.google.com by [email protected]
on 18 Jul 2013 at 7:31
Attachments:
Attached is the svg file I used that was saved from inkscape. svg-android can
parse it. Chrome can parse it.
I have a larger svg with more of these examples if this is insufficient.
E/AndroidRuntime(21629): Caused by: java.lang.NullPointerException
E/AndroidRuntime(21629): at
com.caverock.androidsvg.SVGParser.parsePath(SVGParser.java:3674)
E/AndroidRuntime(21629): at
com.caverock.androidsvg.SVGParser.parseAttributesPath(SVGParser.java:1091)
E/AndroidRuntime(21629): at
com.caverock.androidsvg.SVGParser.path(SVGParser.java:1078)
E/AndroidRuntime(21629): at
com.caverock.androidsvg.SVGParser.startElement(SVGParser.java:629)
E/AndroidRuntime(21629): at
org.apache.harmony.xml.ExpatParser.startElement(ExpatParser.java:143)
E/AndroidRuntime(21629): at
org.apache.harmony.xml.ExpatParser.appendBytes(Native Method)
E/AndroidRuntime(21629): at
org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:513)
E/AndroidRuntime(21629): at
org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474)
E/AndroidRuntime(21629): at
org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:321)
E/AndroidRuntime(21629): at
org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279)
E/AndroidRuntime(21629): at
com.caverock.androidsvg.SVGParser.parse(SVGParser.java:576)
E/AndroidRuntime(21629): at
com.caverock.androidsvg.SVG.getFromResource(SVG.java:172)
Original issue reported on code.google.com by [email protected]
on 7 Jan 2014 at 12:31
Attachments:
If a path has no 'd' attribute, the library crashes with a NullPointerException.
Reported by Igor Stassly.
Original issue reported on code.google.com by [email protected]
on 26 Apr 2014 at 3:58
Along similar lines to the color replacement request, is there a chance of
adding the ability to replace the contents of one or more text elements,
preferably by an ID match, but a regexp based search and replace may also be
useful e.g.
svg.getTextElementById(id).setValue(string);
svg.getTextElementByValue(regexp).setValue(string);
Original issue reported on code.google.com by [email protected]
on 15 Sep 2014 at 8:54
Hi! I'm fairly new to Android development, and I need some help zooming into a
portion of my SVG file on application startup.
From what I understand from the Javadocs, I should use one of the
renderViewToCanvas() methods, but I'm not really sure how to define the viewId.
The API Summary defines the following in the Rendering Views section:
<view id="MyView" viewBox="0 0 100 100"/>
But this is not a valid XML tag... Can someone help me understand how to
properly use renderViewToCanvas() to fit me needs? Thanks in advance.
Original issue reported on code.google.com by [email protected]
on 11 Jul 2014 at 2:51
What steps will reproduce the problem?
1. Load a complex SVG.
What is the expected output? What do you see instead?
I expect to see the SVG.
Instead I get a stack trace...
01-21 16:05:45.683: E/org.jw.jwlibrary.mobile.svg.SvgView(4764):
java.lang.NullPointerException
01-21 16:05:45.683: E/org.jw.jwlibrary.mobile.svg.SvgView(4764): at
com.caverock.androidsvg.SVGParser.parseColourComponent(SVGParser.java:3254)
01-21 16:05:45.683: E/org.jw.jwlibrary.mobile.svg.SvgView(4764): at
com.caverock.androidsvg.SVGParser.parseColour(SVGParser.java:3236)
01-21 16:05:45.683: E/org.jw.jwlibrary.mobile.svg.SvgView(4764): at
com.caverock.androidsvg.SVGParser.parseColourSpecifer(SVGParser.java:3198)
01-21 16:05:45.683: E/org.jw.jwlibrary.mobile.svg.SvgView(4764): at
com.caverock.androidsvg.SVGParser.parsePaintSpecifier(SVGParser.java:3187)
01-21 16:05:45.683: E/org.jw.jwlibrary.mobile.svg.SvgView(4764): at
com.caverock.androidsvg.SVGParser.processStyleProperty(SVGParser.java:2652)
01-21 16:05:45.683: E/org.jw.jwlibrary.mobile.svg.SvgView(4764): at
com.caverock.androidsvg.CSSParser.parseDeclarations(CSSParser.java:736)
01-21 16:05:45.683: E/org.jw.jwlibrary.mobile.svg.SvgView(4764): at
com.caverock.androidsvg.CSSParser.parseRule(CSSParser.java:667)
01-21 16:05:45.683: E/org.jw.jwlibrary.mobile.svg.SvgView(4764): at
com.caverock.androidsvg.CSSParser.parseRuleset(CSSParser.java:649)
01-21 16:05:45.683: E/org.jw.jwlibrary.mobile.svg.SvgView(4764): at
com.caverock.androidsvg.CSSParser.parse(CSSParser.java:293)
01-21 16:05:45.683: E/org.jw.jwlibrary.mobile.svg.SvgView(4764): at
com.caverock.androidsvg.SVGParser.parseCSSStyleSheet(SVGParser.java:3974)
01-21 16:05:45.683: E/org.jw.jwlibrary.mobile.svg.SvgView(4764): at
com.caverock.androidsvg.SVGParser.endElement(SVGParser.java:776)
01-21 16:05:45.683: E/org.jw.jwlibrary.mobile.svg.SvgView(4764): at
org.apache.harmony.xml.ExpatParser.endElement(ExpatParser.java:156)
01-21 16:05:45.683: E/org.jw.jwlibrary.mobile.svg.SvgView(4764): at
org.apache.harmony.xml.ExpatParser.appendBytes(Native Method)
01-21 16:05:45.683: E/org.jw.jwlibrary.mobile.svg.SvgView(4764): at
org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:513)
01-21 16:05:45.683: E/org.jw.jwlibrary.mobile.svg.SvgView(4764): at
org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474)
01-21 16:05:45.683: E/org.jw.jwlibrary.mobile.svg.SvgView(4764): at
org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:321)
01-21 16:05:45.683: E/org.jw.jwlibrary.mobile.svg.SvgView(4764): at
org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279)
01-21 16:05:45.683: E/org.jw.jwlibrary.mobile.svg.SvgView(4764): at
com.caverock.androidsvg.SVGParser.parse(SVGParser.java:576)
01-21 16:05:45.683: E/org.jw.jwlibrary.mobile.svg.SvgView(4764): at
com.caverock.androidsvg.SVG.getFromInputStream(SVG.java:143)
What version of the product are you using? On what operating system?
1.2 on Android 4.0.x
I'm drawing the SVG straight to the canvas in OnDraw()
Original issue reported on code.google.com by [email protected]
on 21 Jan 2014 at 9:02
Not sure if this is a problem of my svg or the lib, in case of the former I am
sorry.
com.caverock.androidsvg.SVGParseException: SVG parse error: Invalid colour
keyword: transparent
at com.caverock.androidsvg.SVGParser.parse(SVGParser.java:406)
at com.caverock.androidsvg.SVG.getFromInputStream(SVG.java:144)
at epaper.android.mineus.de.svgtest.SvgFragment.onCreateView(SvgFragment.java:51)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:938)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1115)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1478)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:478)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1068)
at android.support.v4.view.ViewPager.populate(ViewPager.java:914)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1436)
at android.view.View.measure(View.java:16497)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
at android.view.View.measure(View.java:16497)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:16497)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:327)
at android.view.View.measure(View.java:16497)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291)
at android.view.View.measure(View.java:16497)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1916)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1113)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1295)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:544)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: org.xml.sax.SAXException: Invalid colour keyword: transparent
at com.caverock.androidsvg.SVGParser.parseColourKeyword(SVGParser.java:3066)
at com.caverock.androidsvg.SVGParser.parseColour(SVGParser.java:3041)
at com.caverock.androidsvg.SVGParser.parseColourSpecifer(SVGParser.java:2994)
at com.caverock.androidsvg.SVGParser.parsePaintSpecifier(SVGParser.java:2983)
at com.caverock.androidsvg.SVGParser.processStyleProperty(SVGParser.java:2410)
at com.caverock.androidsvg.CSSParser.parseDeclarations(CSSParser.java:736)
at com.caverock.androidsvg.CSSParser.parseRule(CSSParser.java:667)
at com.caverock.androidsvg.CSSParser.parseRuleset(CSSParser.java:649)
at com.caverock.androidsvg.CSSParser.parse(CSSParser.java:293)
at com.caverock.androidsvg.SVGParser.parseCSSStyleSheet(SVGParser.java:3955)
Original issue reported on code.google.com by [email protected]
on 17 Jun 2014 at 7:49
What steps will reproduce the problem?
1. Fire up N threads that will load the example SVG file
(it doesn't have to be the same file, the key is for all to have named colors
in them)
What is the expected output? What do you see instead?
All pictures load safely instead of
com.caverock.androidsvg.SVGParseException: SVG parse error: Invalid colour
keyword: white
at com.caverock.androidsvg.SVGParser.parse(SVGParser.java:406)
at com.caverock.androidsvg.SVG.getFromResource(SVG.java:187)
at com.squareup.picasso.SVGLoader.load(SVGLoader.java:83)
at com.squareup.picasso.SVGLoader.doInBackground(SVGLoader.java:66)
at com.squareup.picasso.SVGLoader.doInBackground(SVGLoader.java:1)
at ....SimpleAsyncTask.doInBackground(SimpleAsyncTask.java:8)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: org.xml.sax.SAXException: Invalid colour keyword: white
at com.caverock.androidsvg.SVGParser.parseColourKeyword(SVGParser.java:3066)
at com.caverock.androidsvg.SVGParser.parseColour(SVGParser.java:3041)
at com.caverock.androidsvg.SVGParser.parseColourSpecifer(SVGParser.java:2994)
at com.caverock.androidsvg.SVGParser.parsePaintSpecifier(SVGParser.java:2983)
at com.caverock.androidsvg.SVGParser.processStyleProperty(SVGParser.java:2425)
at com.caverock.androidsvg.CSSParser.parseDeclarations(CSSParser.java:736)
at com.caverock.androidsvg.CSSParser.parseRule(CSSParser.java:667)
at com.caverock.androidsvg.CSSParser.parseRuleset(CSSParser.java:649)
at com.caverock.androidsvg.CSSParser.parse(CSSParser.java:293)
at com.caverock.androidsvg.SVGParser.parseCSSStyleSheet(SVGParser.java:3955)
at com.caverock.androidsvg.SVGParser.endElement(SVGParser.java:605)
at org.apache.harmony.xml.ExpatParser.endElement(ExpatParser.java:156)
at org.apache.harmony.xml.ExpatParser.appendBytes(Native Method)
at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:513)
at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474)
at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:316)
at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279)
at com.caverock.androidsvg.SVGParser.parse(SVGParser.java:394)
... 11 more
Please provide any additional information below.
Sample SVG: res/raw/questionmark.svg
<?xml version="1.0"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-25,-25 550 550">
<g transform="translate(250, 250)">
<circle r="250" stroke="black" stroke-width="50" fill="white" />
<text text-anchor="middle" font-size="400" font-weight="bold" dy="125">?</text>
</g>
</svg>
Looking at the code it's clear that the initialise*KeywordsMap usages are not
thread safe despite the synchronized keyword:
The first thread sees a null map and goes to initialize it, first assigning the
new instance of a Map and then filling it.
In the middle of the filling a context switch happens and
the second thread comes it, which sees that the map is not null (no need to
initialize) and goes on using it.
But hey! the first thread didn't finish putting all mappings in, and "white" is
towards the end probably that's why I discovered it.
In general all accesses (read/write) should be synchronized to a shared
resource among Threads.
See
https://code.google.com/p/androidsvg/source/browse/src/com/caverock/androidsvg/S
VGParser.java?spec=svnc0c4748db221100ec54a93c302c59b01e3e0521b&r=ee9fa12ad768142
934e0257c87b572aea6df07d0#3059
(Huh, exactly this part was changed in the last commit)
The pattern
private static synchronized void initialise...Map() {
map = new HashMap();
map.put(...);
}
could be replaced by (but DON'T: see
http://en.wikipedia.org/wiki/Double-checked_locking why not to use it)
private static synchronized void initialise...Map() {
if (SVGParser.map == null) return; // this makes sure that any competing threads coming here will just bail quickly
Map map = new HashMap(); // only the first thread will get here and start initializing the others will be blocked on the method's synchronized
map.put(...);
SVGParser.map = map; // this makes sure that all threads will wait for the initialization, since up until this point they all see an empty map and try to initialize and be blocked
// exiting the method releases the block and all other threads will come in and see that the map is not null (first line)
}
Use this one instead:
http://en.wikipedia.org/wiki/Initialization_on_demand_holder_idiom
Attached is the version updated and tested with:
Runnable run = new Runnable() {
public void run() {
SVGParser parser = new SVGParser();
try {
SVG svg = parser.parse(getResources().openRawResource(R.raw.questionmark));
} catch (NotFoundException ex) {
ex.printStackTrace();
} catch (SVGParseException ex) {
ex.printStackTrace();
}
}
};
Thread[] threads = new Thread[10];
for (int i = 0; i < threads.length; ++i) {
threads[i] = new Thread(run);
}
for (int i = 0; i < threads.length; ++i) {
threads[i].start();
}
The original version
(https://androidsvg.googlecode.com/hg-history/ee9fa12ad768142934e0257c87b572aea6
df07d0/src/com/caverock/androidsvg/SVGParser.java) was throwing 5+ exceptions
every time I executed it; the patched version didn't.
Original issue reported on code.google.com by papp.robert.s
on 17 Aug 2014 at 1:17
Attachments:
What steps will reproduce the problem?
1. Used cloned source code to install androidsvg as a Library Module in IntelliJ
2. The project has minSdkVersion=10 and is built using the Android-2.3.3 SDK
(API 10)
3. Added androidsvg as a new library module to the main project module.
What is the expected output? What do you see instead?
Since I hadn't used anything from androidsvg yet I simply compiled the project.
The compilation failed complaining:
java: <redacted path>/src/com/caverock/androidsvg/SVGImageView.java:164: cannot
find symbol
symbol : variable LAYER_TYPE_SOFTWARE
location: class com.caverock.androidsvg.SVGImageView
What version of the product are you using? On what operating system?
androidsvg 1.2 (I guess, I cloned from the repo today).
Android-2.3.3 running Java6
Please provide any additional information below:
The variable LAYER_TYPE_SOFTWARE shouldn't exist by itself with no declaration.
I am guessing that the code actually wants to use View.LAYER_TYPE_SOFTWARE
(introduced in API 11) but is inhibited by the fact that it needs to use
reflection to cater for lower API Levels.
My Solution:
Based on this hypothesis I simply defined LAYER_TYPE_SOFTWARE using reflection
and let the try-catch block deal with failure for lower API Levels by adding
this line just above the use of LAYER_TYPE_SOFTWARE (on line 164):
int LAYER_TYPE_SOFTWARE = View.class.getField("LAYER_TYPE_SOFTWARE").getInt(new
View(getContext()));
This fixed the compiler error and I was able to use SVGImageView in the layout
files in my project without any more problem.
P.S. Great work on this project.
Original issue reported on code.google.com by [email protected]
on 31 Oct 2013 at 5:25
SVGImageView doesn't properly scale the image. Even if w o h are changed, it
seems that only takes w and preserves aspect ratio
SVGImageView siv = new SVGImageView(this);
siv.setImageResource(R.drawable.image_svg);
int w=100;
int h=100;
RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(w,h);
siv.setLayoutParams(rllp);
Original issue reported on code.google.com by [email protected]
on 7 Jul 2014 at 10:06
Attachments:
Hello,
The attached SVG file crashes the SVGParser.
Here's the stacktrace:
08-21 19:12:59.707: E/ResourceImageItem(16638): Could not load image from
resource
08-21 19:12:59.707: E/ResourceImageItem(16638): java.lang.NullPointerException
08-21 19:12:59.707: E/ResourceImageItem(16638): at
com.caverock.androidsvg.SVGParser.parsePath(SVGParser.java:3648)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
com.caverock.androidsvg.SVGParser.parseAttributesPath(SVGParser.java:1091)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
com.caverock.androidsvg.SVGParser.path(SVGParser.java:1078)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
com.caverock.androidsvg.SVGParser.startElement(SVGParser.java:629)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
org.apache.harmony.xml.ExpatParser.startElement(ExpatParser.java:143)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
org.apache.harmony.xml.ExpatParser.appendBytes(Native Method)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:513)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:321)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
com.caverock.androidsvg.SVGParser.parse(SVGParser.java:576)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
com.caverock.androidsvg.SVG.getFromResource(SVG.java:172)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
uk.ac.ucl.excites.collector.ui.picker.items.ResourceImageItem.setImage(ResourceI
mageItem.java:66)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
uk.ac.ucl.excites.collector.ui.picker.items.ImageItem.createView(ImageItem.java:
38)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
uk.ac.ucl.excites.collector.ui.picker.items.Item.getView(Item.java:36)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
uk.ac.ucl.excites.collector.ui.picker.PickerAdapter.getView(PickerAdapter.java:7
1)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.widget.AbsListView.obtainView(AbsListView.java:2465)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.widget.GridView.onMeasure(GridView.java:1030)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.view.View.measure(View.java:15326)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4876)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.view.View.measure(View.java:15326)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4876)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.view.View.measure(View.java:15326)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4876)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.view.View.measure(View.java:15326)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4876)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.jav
a:2423)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.view.View.measure(View.java:15326)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1974)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1217)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1390)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1113)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4481)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.view.Choreographer.doCallbacks(Choreographer.java:555)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.view.Choreographer.doFrame(Choreographer.java:525)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.os.Handler.handleCallback(Handler.java:615)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.os.Handler.dispatchMessage(Handler.java:92)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.os.Looper.loop(Looper.java:137)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
android.app.ActivityThread.main(ActivityThread.java:4867)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
java.lang.reflect.Method.invokeNative(Native Method)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
java.lang.reflect.Method.invoke(Method.java:511)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
08-21 19:12:59.707: E/ResourceImageItem(16638): at
dalvik.system.NativeStart.main(Native Method)
08-21 19:12:59.737: E/ResourceImageItem(16638): Could not load image from
resource
08-21 19:12:59.737: E/ResourceImageItem(16638): java.lang.NullPointerException
08-21 19:12:59.737: E/ResourceImageItem(16638): at
com.caverock.androidsvg.SVGParser.parsePath(SVGParser.java:3648)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
com.caverock.androidsvg.SVGParser.parseAttributesPath(SVGParser.java:1091)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
com.caverock.androidsvg.SVGParser.path(SVGParser.java:1078)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
com.caverock.androidsvg.SVGParser.startElement(SVGParser.java:629)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
org.apache.harmony.xml.ExpatParser.startElement(ExpatParser.java:143)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
org.apache.harmony.xml.ExpatParser.appendBytes(Native Method)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:513)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:321)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
com.caverock.androidsvg.SVGParser.parse(SVGParser.java:576)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
com.caverock.androidsvg.SVG.getFromResource(SVG.java:172)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
uk.ac.ucl.excites.collector.ui.picker.items.ResourceImageItem.setImage(ResourceI
mageItem.java:66)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
uk.ac.ucl.excites.collector.ui.picker.items.ImageItem.createView(ImageItem.java:
38)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
uk.ac.ucl.excites.collector.ui.picker.items.Item.getView(Item.java:36)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
uk.ac.ucl.excites.collector.ui.picker.PickerAdapter.getView(PickerAdapter.java:7
1)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.widget.AbsListView.obtainView(AbsListView.java:2465)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.widget.GridView.makeAndAddView(GridView.java:1331)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.widget.GridView.makeRow(GridView.java:331)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.widget.GridView.fillDown(GridView.java:283)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.widget.GridView.fillFromTop(GridView.java:407)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.widget.GridView.layoutChildren(GridView.java:1219)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.widget.AbsListView.onLayout(AbsListView.java:2300)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.view.View.layout(View.java:13891)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.view.ViewGroup.layout(ViewGroup.java:4424)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.view.View.layout(View.java:13891)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.view.ViewGroup.layout(ViewGroup.java:4424)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.widget.FrameLayout.onLayout(FrameLayout.java:448)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.view.View.layout(View.java:13891)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.view.ViewGroup.layout(ViewGroup.java:4424)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.view.View.layout(View.java:13891)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.view.ViewGroup.layout(ViewGroup.java:4424)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.widget.FrameLayout.onLayout(FrameLayout.java:448)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.view.View.layout(View.java:13891)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.view.ViewGroup.layout(ViewGroup.java:4424)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1992)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1813)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1113)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4481)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.view.Choreographer.doCallbacks(Choreographer.java:555)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.view.Choreographer.doFrame(Choreographer.java:525)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.os.Handler.handleCallback(Handler.java:615)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.os.Handler.dispatchMessage(Handler.java:92)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.os.Looper.loop(Looper.java:137)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
android.app.ActivityThread.main(ActivityThread.java:4867)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
java.lang.reflect.Method.invokeNative(Native Method)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
java.lang.reflect.Method.invoke(Method.java:511)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
08-21 19:12:59.737: E/ResourceImageItem(16638): at
dalvik.system.NativeStart.main(Native Method)
Original issue reported on code.google.com by [email protected]
on 21 Aug 2013 at 6:15
Attachments:
What steps will reproduce the problem?
1. read svhttps://code.google.com/p/androidsvg/issues/entryg resource from
input stream stored inside a jar file
2. renderToPicture
3. set PictureDrawable to a ImageView.
What is the expected output? What do you see instead?
The image renders, however the image is blurry.
What version of the product are you using? On what operating system?
news beta version. android 4.02
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 3 Jul 2014 at 4:27
What steps will reproduce the problem?
I want to assign svg-images for button via xml-selector.
In my project folder \res\drawable\ you can see:
btn_play.xml - this is a xml-selector
img_play.svg
img_play_pressed.svg
The content of "btn_play.xml" :
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE xml> <selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/img_play_pressed" android:state_focused="true" android:state_pressed="true"/> <item android:drawable="@drawable/img_play_pressed" android:state_focused="false" android:state_pressed="true"/> <item android:drawable="@drawable/img_play_pressed" android:state_focused="true"/> <item android:drawable="@drawable/img_play" android:state_focused="false" android:state_pressed="false"/>
</selector>
It's works for png-images but don't works for svg.
I expect that button will use assigned svg-images like png-images but in
run-time I don't see any pictures.
I used the version 1.2 on android 4.x
Original issue reported on code.google.com by [email protected]
on 13 Jun 2014 at 9:06
Looks like ACID SVG test was updated and now androidsvg cant render it correctly
Original issue reported on code.google.com by [email protected]
on 27 Aug 2013 at 8:25
If there is some attributes not supported, the SVG can't be shown.
Such as: stroke-linecap="null" stroke-linejoin="null"
If it possible for just ignore these attributes in text element?
Original issue reported on code.google.com by [email protected]
on 6 Jan 2014 at 7:15
I want to put the zoom function scaled SVG
Original issue reported on code.google.com by [email protected]
on 12 Aug 2014 at 10:20
The problem.
If I have a Canvas canv and a Paint paint which I use to draw some text and svg
images then the following calls don't produce the same
svg.renderToCanvas(canv,frame);
canv.drawText(""+initiative,shift,textHeight,paint);
or
canv.drawText(""+initiative,shift,textHeight,paint);
svg.renderToCanvas(canv,frame);
I'm not completely sure this is a bug but it took me some time to understand
this. I'm using androidsvg-1.2.1.
Now that I understood this I'm working with the workaround
canv.save();
svg.renderToCanvas(canv,frame);
canv.restore();
canv.drawText(""+initiative,shift,textHeight,paint);
Original issue reported on code.google.com by [email protected]
on 14 Jan 2015 at 4:43
It seems Corel Draw generates SVG files that use a CSS stylesheet to define all
it's object style attributes.
There is a sample file at:
http://code.google.com/p/svg-android/issues/detail?id=46
I don't want to burden AndroidSVG with a full CSS parser, but one of the goals
is to support files generated by popular vector editors. I may need to add a
basic CSS parser.
Original issue reported on code.google.com by [email protected]
on 12 Feb 2013 at 1:31
What steps will reproduce the problem?
1. Load attached "test1.svg" in SVGImageView.
What is the expected output? What do you see instead?
It contains three embeded pngs. Opening this svg in IE9 shows embeded pngs
correctly any time i load svg.
What i see:
Sometimes after rendering images, i see "trashed" images instead of real.
What version of the product are you using? On what operating system?
1.2.0.
OS: Android 4.1.2.
Hardware Galaxy Note 10.1 (2012 year)
Original issue reported on code.google.com by [email protected]
on 17 Dec 2013 at 10:07
Attachments:
Will be very usefull to add SVGLinearLayout, SVGRelativeLayout etc. with
opportunity to set background as svg file according to SVGImageView.
Original issue reported on code.google.com by [email protected]
on 14 Aug 2013 at 9:47
Hello and thank you for gread library!
I'm trying to use it in my app.
Idea is to use svg icons, and render them to bitmap cache objects to fit
different screen resolutions.
Here is code example.
SVG svg = SVG.getFromResource(getActivity(), R.raw.avatar_default);
Bitmap mBitmap = Bitmap.createBitmap(300, 300, Bitmap.Config.ARGB_8888);
Canvas c=new Canvas(mBitmap);
svg.renderToCanvas(c);
img.setImageBitmap(mBitmap);
by passing width, height I assume to scale svg to fit bitmap rectangle.
Here is example in attachment.
Selected picture is one from code above. How to scale svg to different size
canvas?
I also attach couple source pictures from grid on screenshot. As you see, when
I'm trying to render svg with defaults 96x96 to 120x120 pixels Canvas\Bitmap
I've got artefacts on picture...
I tried different scale modes on ImageViews but no luck :(
Original issue reported on code.google.com by [email protected]
on 21 Oct 2013 at 11:52
Attachments:
Bitmap bm = Bitmap.createBitmap((int) w, (int) h, Bitmap.config.ALPHA_8);
Canvas bmcanvas = new Canvas(bm);
// Render our document scaled to fit inside our canvas dimensions
svg.renderToCanvas(bmcanvas, null, 96f, AspectRatioAlignment.xMidYMid,
AspectRatioScale.MEET);
What is the expected output? What do you see instead?
I expected bm to be a grayscale bitmap, instead it is all black.
What version of the product are you using? On what operating system?
Latest
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 17 Jun 2013 at 7:32
We are using svg-android-2 in the mapsforge project.
But with a main change, the use of the kXML library which speeds up SVG parsing
considerably, compared with the SAX version.
I have tried also androidsvg which seems to use SAX.
Though it could render more svg files, it's slower than above implementation.
Have you considered using a faster SVG parser like the kXML?
Original issue reported on code.google.com by [email protected]
on 11 Jun 2014 at 8:02
I decided to run all of my SVG files through AndroidSVG to see if any others
would have rendering issues (similar to Issue 13) when strange error came up:
01-14 14:35:11.489 6353-6353/hell.go.whatevapp W/dalvikvm﹕ JNI WARNING:
NewStringUTF input is not valid Modified UTF-8: illegal start byte 0xf0
01-14 14:35:11.489 6353-6353/hell.go.whatevapp W/dalvikvm﹕ string: '𠂊'
01-14 14:35:11.489 6353-6353/hell.go.whatevapp W/dalvikvm﹕ in
Lorg/apache/harmony/xml/ExpatAttributes;.getValueByIndex:(JI)Ljava/lang/String;
(NewStringUTF)
01-14 14:35:11.489 6353-6353/hell.go.whatevapp I/dalvikvm﹕ "main" prio=5
tid=1 NATIVE
01-14 14:35:11.489 6353-6353/hell.go.whatevapp I/dalvikvm﹕ | group="main"
sCount=0 dsCount=0 obj=0x41cf3e28 self=0x41ce24c0
01-14 14:35:11.489 6353-6353/hell.go.whatevapp I/dalvikvm﹕ | sysTid=6353
nice=0 sched=0/0 cgrp=apps handle=1074098516
01-14 14:35:11.489 6353-6353/hell.go.whatevapp I/dalvikvm﹕ | state=R
schedstat=( 0 0 0 ) utm=1186 stm=23 core=1
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ #00 pc
0000132e /system/lib/libcorkscrew.so (unwind_backtrace_thread+29)
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ #01 pc
0006353e /system/lib/libdvm.so (dvmDumpNativeStack(DebugOutputTarget const*,
int)+33)
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ #02 pc
00057514 /system/lib/libdvm.so (dvmDumpThreadEx(DebugOutputTarget const*,
Thread*, bool)+395)
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ #03 pc
00057582 /system/lib/libdvm.so (dvmDumpThread(Thread*, bool)+25)
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ #04 pc
0003b4d4 /system/lib/libdvm.so
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ #05 pc
0003c90c /system/lib/libdvm.so
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ #06 pc
0003ecde /system/lib/libdvm.so
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ #07 pc
00014396 /system/lib/libjavacore.so
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ #08 pc
0002034c /system/lib/libdvm.so (dvmPlatformInvoke+112)
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ #09 pc
00050e6a /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*,
Method const*, Thread*)+397)
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
org.apache.harmony.xml.ExpatAttributes.getValueByIndex(Native Method)
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
org.apache.harmony.xml.ExpatAttributes.getValue(ExpatAttributes.java:72)
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
com.caverock.androidsvg.SVGParser.parseAttributesStyle(SVGParser.java:2571)
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
com.caverock.androidsvg.SVGParser.g(SVGParser.java:913)
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
com.caverock.androidsvg.SVGParser.startElement(SVGParser.java:623)
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
org.apache.harmony.xml.ExpatParser.startElement(ExpatParser.java:143)
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
org.apache.harmony.xml.ExpatParser.appendBytes(Native Method)
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:513)
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474)
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:316)
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279)
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
com.caverock.androidsvg.SVGParser.parse(SVGParser.java:576)
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
com.caverock.androidsvg.SVG.getFromInputStream(SVG.java:143)
01-14 14:35:11.495 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
hell.go.whatevapp.MainActivity.onCreate(MainActivity.java:73)
01-14 14:35:11.496 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
android.app.Activity.performCreate(Activity.java:5260)
01-14 14:35:11.496 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
01-14 14:35:11.496 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2154)
01-14 14:35:11.496 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
01-14 14:35:11.496 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
android.app.ActivityThread.access$700(ActivityThread.java:139)
01-14 14:35:11.496 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1411)
01-14 14:35:11.496 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
android.os.Handler.dispatchMessage(Handler.java:102)
01-14 14:35:11.496 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
android.os.Looper.loop(Looper.java:137)
01-14 14:35:11.496 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
android.app.ActivityThread.main(ActivityThread.java:5083)
01-14 14:35:11.496 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
java.lang.reflect.Method.invokeNative(Native Method)
01-14 14:35:11.496 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
java.lang.reflect.Method.invoke(Method.java:515)
01-14 14:35:11.496 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
01-14 14:35:11.496 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
01-14 14:35:11.496 6353-6353/hell.go.whatevapp I/dalvikvm﹕ at
dalvik.system.NativeStart.main(Native Method)
I still have about 6000 of 6700 images to run through, but so far this error is
constant across all of the 10 files (the character in the second line is
different for some of them, but the line preceding it and the lines following
it are identical across all files).
I'm sure there will be others, but here are the two different unicode values
that have caused this error so far:
U+20509
U+2008A
Original issue reported on code.google.com by [email protected]
on 14 Jan 2014 at 11:06
What steps will reproduce the problem?
The following method draws a circle filled with blue surrounded by a white
line:
public void drawBlue(Canvas c) {
Paint p = new Paint();
p.setColor(Color.BLUE);
RectF rect = new RectF(0, 0, 200, 200);
Picture pic = new Picture();
Canvas canvas = pic.beginRecording(200, 200);
canvas.drawOval(rect, p);
pic.endRecording();
RectF dest = new RectF(200, 200, 400, 400);
c.save();
c.translate(200, 200);
c.drawPicture(pic, rect);
c.restore();
p.setColor(Color.WHITE);
p.setStrokeWidth(2);
p.setStyle(Paint.Style.STROKE);
c.drawOval(dest, p);
}
Now I've replace the Picture in the above code with a picture generated from
SVG:
public void drawSphere(Canvas c) {
Paint p = new Paint();
p.setColor(Color.BLUE);
RectF rect = new RectF(0, 0, 200, 200);
Picture pic = new Picture(ball.renderToPicture(200, 200));
assert(pic.getWidth() == 200 && pic.getHeight() == 200);
RectF dest = new RectF(400, 400, 600, 600);
c.save();
c.translate(400, 400);
c.drawPicture(pic, rect);
c.restore();
p.setColor(Color.WHITE);
p.setStrokeWidth(2);
p.setStyle(Paint.Style.STROKE);
c.drawOval(dest, p);
}
where ball = SVG.getFromResource(ctx, R.raw.sphere);
What is the expected output? What do you see instead?
I'd expect to see two white circles, one filled with blue, the other filled a
pictures corresponding the svg file in R.raw.sphere.
But instead I'm getting a view as in the attached screenshot.
What version of the product are you using? On what operating system?
androidsvg-1.2.1.jar, android 4.4.2
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 10 Mar 2014 at 8:14
Attachments:
What steps will reproduce the problem?
1. Attempting to add an SVGImageView with a RelativeLayoutParams
2. I get a DALVIK error - 11-19 13:23:06.755: W/dalvikvm(4600): VFY: unable to
resolve static field 1107 (SVGImageView) in
Lcom/caverock/androidsvg/R$styleable;
3. And no image is displayed - just the white background
What is the expected output? What do you see instead?
A rendered svg image. Image in question works fine,
when not using the SVGImageView
What version of the product are you using? On what operating system?
1-2-0
Happy to provide more details, code etc. Wanted to see if you had any initial
thoughts?
Thanks,
Rod
Original issue reported on code.google.com by [email protected]
on 19 Nov 2013 at 1:53
What steps will reproduce the problem?
1. Declare the SVGImageView in a layout file (xml)
2. Specify an asset file using the "svg" attribute.
What is the expected output? What do you see instead?
The svg is rendered correctly and the app runs fine. However logcat is filled
with Warnings for behavior that should be handled more gracefully and doesn't
need warnings to be raised.
What version of the product are you using? On what operating system?
1.2 I think. I cloned the repo today.
Android 2.3.3 (API 10)
Please provide any additional information below.
One example is SVGImageView.internalSetImageURI(Uri uri) on line 138: is =
getContext().getContentResolver().openInputStream(uri);
If one chooses to specify an asset file in the "svg" attribute than the uri is
a string containing the relative path of the svg file in the assets/ folder.
Clearly this will cause the above line to fail and throw an exception.
This behavior is expected however, based on how the "svg" attribute accepts
multiple possible inputs (as defined in
https://code.google.com/p/androidsvg/wiki/SVGImageView). Unfortunately the code
captures the exception using a generic Exception (frowned upon behavior) and
then writes a warning log (for expected behavior).
Solution:
Use specific Exceptions to catch the various possibilities and handle them
accordingly. For instance I prefixed the general Exception catch with this
single line:
catch (FileNotFoundException e) { return false; }
No more warnings for expected behavior.
Original issue reported on code.google.com by [email protected]
on 31 Oct 2013 at 8:11
What steps will reproduce the problem?
1. Render the attached SVG file. When I rotate my tablet, causing the image to
repeatedly render to the Canvas, I see different results. Mainly the errors
consist of different areas of the face being incorrectly shaded. There is also
frequently a line across the ear on the left side of the image.
What is the expected output? What do you see instead?
Shading does not look quite right, as if colors were being reused in the wrong
place. At least once (see attached) many polygons were missing and the
background showed through.
What version of the product are you using? On what operating system?
android-svg-1.2.1 on a Nexus 7, Android 4.4.2. Problem also exhibits on a
Motorola Xoom, Android 4.1.2.
Original issue reported on code.google.com by [email protected]
on 4 Feb 2014 at 7:08
Attachments:
Hello Paul,
I've cloned your project and implemented support for SVGZ files/streams (i.e.
GZIP-ed SVG):
https://code.google.com/r/matthiasstevens-androidsvg/source/detail?r=415fb0a7a77
2120cc7b35b0c71217f738030fdee
It only requires 22 of added lines in SVGParser (including comments).
I found the code to do this in one of the many svg-android forks (URL is in the
commit message). But I've made a slight improvement to it which avoids crashes
in case of InputStreams that don't support mark()/reset().
I've tested this with various svgz files. Try for yourself with the attached
file.
I think it would be great if you would incorporate this in your library.
Thanks in advance,
Matthias
Original issue reported on code.google.com by [email protected]
on 21 Aug 2013 at 7:25
Attachments:
The generic font types are currently not supported. AndroidSVG always selects
the DEFAULT typeface by default. However the Typeface class allows you to
choose between SANS_SERIF, SERIF, and MONOSPACE and we should probably support
them.
Original issue reported on code.google.com by [email protected]
on 2 Feb 2013 at 7:12
What steps will reproduce the problem?
1. Create an android activity that does not use themes
2. Initialize the SVGImageView class
3. java.lang.NoClassDefFoundError: com.caverock.androidsvg.R$styleable in
SVGImageView.init at
com.caverock.androidsvg.SVGImageView.init(SVGImageView.java:80)
What is the expected output? What do you see instead?
Fatal error when reaching this line in the init() function on line 80
TypedArray a = getContext().getTheme().obtainStyledAttributes(attrs,
R.styleable.SVGImageView, defStyle, 0)
As a Hackish fix, i prepended a check for existence of the class before this
line & it seems to work for me
try {
Class.forName( "R.styleable.SVGImageView" );
} catch( ClassNotFoundException e ) {
return;
}
What version of the product are you using? On what operating system?
version 1.2.1 on JellyBean
Original issue reported on code.google.com by [email protected]
on 23 Mar 2014 at 7:28
What steps will reproduce the problem?
Any use of the SVGImageView included in XML.
What is the expected output? What do you see instead?
Expect image to be loaded. There's a slight delay and it pops in.
What version of the product are you using? On what operating system?
1.2.2-beta-1 Nexus 4 running 4.4.4
Please provide any additional information below.
In this version there's a delay between when the view is shown and when the
image actually appears. It occurs whether the image resource is set in XML or
set in code via .setImageResource(). I'm using R.raw.someicon resources. I just
switched to using 1.2.1 and it doesn't have this problem. Just wanted to make
sure it was a known issue.
Original issue reported on code.google.com by [email protected]
on 15 Aug 2014 at 2:12
Publish your (awesome) library into a maven repository (google-code hosted or
central repository)
Thank you
Original issue reported on code.google.com by [email protected]
on 1 Mar 2013 at 9:09
I'm using AndroidSVG to display SVG kanji stroke diagrams. When I try to
display one diagram in particular a Null Pointer Exception is caught. Here's
the stack trace from a recent occurrence:
java.lang.NullPointerException
at com.caverock.androidsvg.SVGParser.parsePath(SVGParser.java:3674)
at com.caverock.androidsvg.SVGParser.parseAttributesPath(SVGParser.java:1091)
at com.caverock.androidsvg.SVGParser.path(SVGParser.java:1078)
at com.caverock.androidsvg.SVGParser.startElement(SVGParser.java:629)
at org.apache.harmony.xml.ExpatParser.startElement(ExpatParser.java:143)
at org.apache.harmony.xml.ExpatParser.appendBytes(Native Method)
at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:513)
at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474)
at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:316)
at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279)
at com.caverock.androidsvg.SVGParser.parse(SVGParser.java:576)
at com.caverock.androidsvg.SVG.getFromInputStream(SVG.java:143)
at com.gshoapp.DialogStrokeOrder.onCreateDialog(DialogStrokeOrder.java:67)
at android.app.DialogFragment.getLayoutInflater(DialogFragment.java:398)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
at android.app.BackStackRecord.run(BackStackRecord.java:684)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1447)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
And here's line 66 and 67 from my code:
InputStream is = new BufferedInputStream(new FileInputStream(svgPath));
SVG svg = SVG.getFromInputStream(is);
The code was able to handle the other dozen or so diagrams I threw at it, so I
think the problem might be somewhere in AndroidSVG. After some testing I've
determined that it's not an issue of the file not existing - I've verified that
it's in the proper directory. In an effort to isolate it from potential issues
from my code, I attempted to load the SVG in a separate, basic app that I
drafted exclusively to test AndroidSVG functionality; that app threw the same
error.
I've attached the image that causes the issue, I hope it helps. If it's an
issue of a malformed SVG, let me know and I'll redirect the issue to the group
responsible for making the original file.
Original issue reported on code.google.com by [email protected]
on 13 Jan 2014 at 11:01
Attachments:
I am using the following code from the home page:
// Render our document scaled to fit inside our canvas dimensions
svg.renderToCanvas(bmcanvas, null, 96f, AspectRatioAlignment.xMidYMid, AspectRatioScale.MEET);
In version 1.1.82 the svg is not scaled on the bitmap (an svg 240x400 takes
only a part of 500x500 bitmap), although in 1.1.70 everything is ok, the svg
occupies the whole bitmap.
I am using android 4.1.2 if that matters.
Original issue reported on code.google.com by grebenyuksv
on 6 Jun 2013 at 8:36
What steps will reproduce the problem?
1. Use an SVGImageView in an xml layout.
2. Don't define the svg attribute since you want to specify the image later,
programmatically. This is a feature that ImageView has.
What is the expected output? What do you see instead?
I expect the SVGImageView to show up empty if setImageAsset() is NOT called
programmatically. It it is called I expect the specified image to show.
Instead the app crashes since SVGImageView.java:81 tries to parse a null "url"
and throws NullPointerException.
What version of the product are you using? On what operating system?
1.2 I believe. I cloned the repo today.
Android 2.3.3 (API 10)
Please provide any additional information below.
The exception is being thrown because not specifying the svg attribute in the
xml when declaring an SVGImageView means line 80 of SVGImageView.java:
String url = a.getString(R.styleable.SVGImageView_svg);
returns url equal to null. But this is expected behaviour. The view should just
shrug this off and wait for setImageAsset() or something similar to be called
later.
Solution:
Wrap lines 81-87 in an if statement that verifies that (url != null) before
continuing inside. I implemented this change and the app worked flawlessly.
Original issue reported on code.google.com by [email protected]
on 31 Oct 2013 at 7:59
As in SVG, <g> tag can be also used as layer. It may be very useful if we can
render a specific group by attribute "id"
Original issue reported on code.google.com by [email protected]
on 28 Aug 2013 at 2:25
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.