I gave it a try and all it does is make the app restart with no
error.

On Jan 4, 12:09 pm, "Sergey Ten" <sergey....@zumobi.com> wrote:
> I have not tried it myself, but looks like you can use Picture class.
> E.g:
>
>       �...@override protected void onDraw(Canvascanvas) {
>
>                 FileInputStream in = null;
>                         try {
>                                 in = new FileInputStream("myimage.jpg");
>                         } catch (FileNotFoundException e) {
>                                 // TODO Auto-generated catch block
>                                 e.printStackTrace();
>                         }
>
>                 Bitmap bitmapOrg = BitmapFactory.decodeStream(in);
>
>             int wd = bitmapOrg.getWidth();
>             int hd = bitmapOrg.getHeight();
>
>                 Picture newPicture = Picture.createFromStream(in);
>                CanvasnewCanvas = newPicture.beginRecording(wd, hd);
>             newCanvas.drawBitmap(bitmapOrg, 0, 0, null);
>             newCanvas.drawBitmap(bitmapOrg, wd, 0, null);
>             newCanvas.drawBitmap(bitmapOrg, 0, hd, null);
>             newCanvas.drawBitmap(bitmapOrg, wd, hd, null);
>                 newPicture.endRecording();
>
>             FileOutputStream fos = null;
>             try {
>                         fos = new FileOutputStream("/sdcard/test.png");
>                 } catch (FileNotFoundException e) {
>                         e.printStackTrace();
>                 }
>                 newPicture.writeToStream(fos);
>
> BTW, since you are accessing in and fos outside of try blocks, the app
> can throw NPE.
>
> Sergey
>
>
>
> -----Original Message-----
> From: android-developers@googlegroups.com
>
> [mailto:android-develop...@googlegroups.com] On Behalf Of Protocol-X
> Sent: Sunday, January 04, 2009 5:27 AM
> To: Android Developers
> Subject: [android-developers] Problem savingcanvasto file
>
> Ive been searching all ove on how to edit a image andsaveit. The
> only way i have come accross other than just changing the size or
> orientation is to usecanvas.  Nowcanvasworks fine but i cannot seem
> tosavethe newley created image.. the image always returns the
> original image.
>
>       �...@override protected void onDraw(Canvascanvas) {
>
>                 FileInputStream in = null;
>                         try {
>                                 in = new FileInputStream("myimage.jpg");
>                         } catch (FileNotFoundException e) {
>                                 // TODO Auto-generated catch block
>                                 e.printStackTrace();
>                         }
>
>                 Bitmap bitmapOrg = BitmapFactory.decodeStream(in);
>
>             int wd = bitmapOrg.getWidth();
>             int hd = bitmapOrg.getHeight();
>
>            canvas.drawBitmap(bitmapOrg, 0, 0, null);
>            canvas.drawBitmap(bitmapOrg, wd, 0, null);
>            canvas.drawBitmap(bitmapOrg, 0, hd, null);
>            canvas.drawBitmap(bitmapOrg, wd, hd, null);
>
>            canvas.save();
>
>               FileOutputStream fos = null;
>               try {
>                                 fos = new
> FileOutputStream("/sdcard/test.png");
>                         } catch (FileNotFoundException e) {
>
>                                 e.printStackTrace();
>                         }
>                         bitmapOrg.compress(Bitmap.CompressFormat.PNG,
> 50, fos);
>
>              try {
>                                 fos.close();
>                         } catch (IOException e) {
>
>                                 e.printStackTrace();
>                         }
>         }- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to