Canvas image blur when multiple time load and save in canvas

74 views
Skip to first unread message

Sanjay Sangwan

unread,
Mar 2, 2019, 9:07:57 AM3/2/19
to mitappinv...@googlegroups.com
Hello everyone,

I am stuck at the program, where i am loading the image in canvas and save again multiple time. After every time save, its getting blur. Image attached. Pls help me. Thanks in advance.

Sanjay Sangwan
12.png
2.png
Screenshot from 2019-03-02 19-18-49.png

Chris Ward

unread,
Mar 2, 2019, 9:31:46 AM3/2/19
to MIT App Inventor Forum
Hello Sanjay

Unfortunately, that is a limitation of App Inventor's Canvas Gadget. 

SteveJG

unread,
Mar 2, 2019, 9:59:55 AM3/2/19
to MIT App Inventor Forum
@ Chris  This behavior is not a limitation of App Inventor's Canvas.   The Canvas is part of Android's operating system  https://developer.android.com/reference/android/graphics/Canvas .  The Canvas Object merely provides access to the capability of the Android operating system tools.

@ Sanjay  Make a copy of a copy of a copy using any technique and eventually the final copy loses resolution Sanjay.   Exactly why this happens with your app may have to do with pixel resolution of your device, how you display the image (whether you display it 1:1 or allow the software to shrink the image to fit the Canvas) or something else beyond the capabilities of even the professional compilers.



Regards,
Steve

TimAI2

unread,
Mar 2, 2019, 12:10:24 PM3/2/19
to MIT App Inventor Forum
There is a possible, but complicated, workaround, whereby you save the drawing action coordinates rather than the actual drawing, then load these for next time.

Would need to more fully understand your workflow in the canvas to explain further and give examples

See here:


and here

Chris Ward

unread,
Mar 2, 2019, 1:19:41 PM3/2/19
to MIT App Inventor Forum
Hi Steve

I believe it really is our limitation, if not in fact a bug, caused by our implementation of the Android Canvas and how the save function works in particular. 
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Italo

unread,
Mar 3, 2019, 3:51:03 PM3/3/19
to mitappinv...@googlegroups.com
I believe in fact it is a bug of App Inventor, since you can save a picture in the canvas, in FIXED mode and the picture doesn't degrade too much. 
The bigger degradation (I think due to a high compression value) only happens when the screen is set to RESPONSIVE.
Outside App Inventor, that kind of blurring usually happens when saving a JPG with a compression of 85% or more, but in App Inventor, it happens even when saving in PNG format.

SteveJG

unread,
Mar 3, 2019, 5:55:15 PM3/3/19
to MIT App Inventor Forum
I do not believe this is a bug in AI.   It is the way App Inventor is designed.   In order for AI to handle graphics simply, the development team came up with compromise code that scales  the screen.
Copy of a copy of a copy of a copy will become blurred.  

Chris Ward

unread,
Mar 3, 2019, 8:16:57 PM3/3/19
to MIT App Inventor Forum
Hi Steve

Your explanation really cements the view that the fault is App Inventor's "compromise code". Even a single save results in some degradation and it should be possible to make multiple copies without any degradation. Perhaps Canvas Save File could be set aside as an assignment for an Undergrad to tackle.
Reply all
Reply to author
Forward
0 new messages