The main reason I never use save is because it is not properly documented:
public int *save *(int saveFlags) Since: API Level 1<http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels> Based on saveFlags, can save the current matrix and clip onto a private stack. Subsequent calls to translate,scale,rotate,skew,concat or clipRect,clipPath will all operate as usual, but when the balancing call to restore() is made, those calls will be forgotten, and the settings that existed before the save() will be reinstated. *Parameters* *saveFlags* flag bits that specify which parts of the Canvas state to save/restore *Returns* - The value to pass to restoreToCount() to balance this save() - I think the docs ought to say what saveFlags is. And, yes, you can always multiply by the inverse to undo an operation. On Wednesday, September 12, 2012 1:19:29 PM UTC-5, NikDmit wrote: > > Thank you for you answer! > > I guess that will do. But I found out important thing in API's, there are > two methods related to this problem ( save and restore ) in Canvas class. > Also, I played a bit around with rotation and there is another way to > rotate only one shape on the canvas: > > canvas.rotate(90, startX, startY); > canvas.drawLine(...); > canvas.rotate(-90, startX, startY); > > canvas.drawCircle(...); //Will not be rotated > > On Wednesday, September 12, 2012 8:43:38 PM UTC+3, bob wrote: >> >> How about this? >> >> >> >> final Matrix backup_matrix = canvas.getMatrix(); >> >> >> // do whatever rotation, etc… drawing >> >> >> >> canvas.setMatrix(backup_matrix); >> >> >> On Wednesday, September 12, 2012 11:02:15 AM UTC-5, NikDmit wrote: >>> >>> Thank you, for your response. I'm sorry, I've removed my last post. >>> Actually it doesn't work. You see, if you'll define a new matrix and set it >>> up for the canvas, everything will be moved up by 100 pixels. And that is >>> not, what I expected. It seems, that the only option is to draw the line on >>> a Bitmap and draw the bitmap after all. A single bitmap can be drawn with >>> transformation matrix, but not a single shape. Guys, if you have some other >>> ideas, how it could be done without using OpenGL, please, let me know. >>> Thank you. >>> >>> On Tuesday, September 11, 2012 9:32:30 PM UTC+3, bob wrote: >>>> >>>> Use this to reset the canvas after drawing your one >>>> rotated/scaled/whatever object: >>>> >>>> >>>> canvas.setMatrix(new Matrix()); >>>> >>>> On Tuesday, September 11, 2012 1:18:53 PM UTC-5, NikDmit wrote: >>>>> >>>>> Hello. >>>>> >>>>> Since it's very possible to apply rotation and translation to the >>>>> entire canvas and Bitmap's object, I have a question, is it possible, >>>>> without using OpenGL, to apply rotation and translation only for one >>>>> element on the canvas? Let's say, I draw line and circle and I want to >>>>> apply translation only for the line, not for the entire view. With concat >>>>> method of the Canvas the entire view will be changed(translated or >>>>> rotated). >>>>> >>>>> Thank you for your answers beforehand. >>>>> >>>> -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

