Page 1 of 1
Canvas restore underflow after image export
Posted: Sat Mar 16, 2013 10:27 pm
by 17064597
I do this to export an image from my area chart (painted with SeriesBand):
Code: Select all
chart.doInvalidate();
Image img = chart.getExport().getImage().image(WIDTH, HEIGHT);
chart.doInvalidate();
That works the first time. The second time it crashes on the call to restore() in Graphics3DAndroid.java.
Code: Select all
public void unClip() {
canvas.restore();
//canvas.clipRect(0, 0, bounds.width, bounds.height, android.graphics.Region.Op.INTERSECT);
}
java.lang.IllegalStateException: Underflow in restore
Why do I end up in an erroneous state? Sure looks like a bug!
Re: Canvas restore underflow after image export
Posted: Sat Mar 16, 2013 10:58 pm
by 17064597
Please post a source code fix here as soon as possible. This is a blocker for my app
I'll see if I can fix it until then! Thanks.
Re: Canvas restore underflow after image export
Posted: Sat Mar 16, 2013 11:14 pm
by 17064597
Ok, found a fix. Please verify that this is the right way to solve this!
Code: Select all
public Image image(int width, int height) {
final Object old = androidGraphics.getGraphics();
Image i = new Image(width, height);
Canvas c = new Canvas(i.bitmap);
// FIX: Explicitly call save() to allow for canvas.restore() later on.
c.save();
Re: Canvas restore underflow after image export
Posted: Tue Mar 19, 2013 11:38 am
by yeray
znakeeye wrote:I do this to export an image from my area chart (painted with SeriesBand):
Code: Select all
chart.doInvalidate();
Image img = chart.getExport().getImage().image(WIDTH, HEIGHT);
chart.doInvalidate();
That works the first time. The second time it crashes on the call to restore() in Graphics3DAndroid.java.
Code: Select all
public void unClip() {
canvas.restore();
//canvas.clipRect(0, 0, bounds.width, bounds.height, android.graphics.Region.Op.INTERSECT);
}
java.lang.IllegalStateException: Underflow in restore
Why do I end up in an erroneous state? Sure looks like a bug!
I'm not able to reproduce it in an Android 4.2 emulator.
Could you please attach a simple example project we can run as-is to reproduce the problem here?
Thanks in advance.