android - Draw on a large canvas, scroll it, save it, reload it ... works, but only the viewport part is saved -


My program can draw 2D size on a canvas, the result can be scrolled, when I save the result Only viewport image is saved.

I use a scene and drag it to the canvas

Saving drawing / updated result:

  set drawing caches (true) ); BuildDrawingCache (); Bitmap BMP = bitmap.creditbetaMap (this.getDrawingCache ()); SetDrawingCacheEnabled (false); // bitmap I can save a file in bm.compress (bitmap.compress format.png, 90, new fileoptputstream (new file (file path));  

When I use a large view / canvas, I get errors, which is not quite big in my drawing catcher. When I use a regulator view / canvas shape, there are almost all drawing clips outside the viewport.

==> Can I draw on a bitmap and immediately drag that bitmap onto the canvas of the scene?

So, after some drawing, the initial bitmap is updated with the newly added drawing?

Happy, there is a simple solution to this question

  1. Make a big bitmap with size;
  2. Create your cached canvas = new canvas (big bitmap);
  3. First draw on the cached canvas'
  4. On-the-do (): Canvas leftbitmap (Cached bitmap, 0, 0, empty);

Saving your big bitmap is easy!


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -