image - Unable to save multiple Bitmaps with OutputStream/FileOutputStream in Android -


currently,i'm having double trouble.

  1. unable crop bitmap.
  2. unable save multiple bitmaps.

    recently, i've made camera app saves jpeg image sd card without frail, however, wanted crop bitmap , save 2 parts (save 2 images same folder). however, i'm unable crop bitmaps in current code.

and second problem tested , tried save same bitmaps testing purpose same folder using fileoutputstreams failed.(actually want save cropped version of bitmap).

everything seemed well, until now. since i'm noob may missing or may have done nonsense codes. i've put codes (method) tried , failed.

public static void makerotateimage(activity activity, byte[] data, int maxpixel) {          // original bitmap         bitmap bitmapsrc = maketargetpixelimage(data, maxpixel);          // degrees         int degree = getcameradisplayorientation(activity);         int destwidth = 0;         int destheight = 0;          //alter or rotate         if (degree % 180 == 0) {             destwidth = bitmapsrc.getwidth();             destheight = bitmapsrc.getheight();         } else {             destwidth = bitmapsrc.getheight();             destheight = bitmapsrc.getwidth();         }          // creating new bitmap + i'm not sure things screwing around here          bitmap bitmapdest = bitmap.createbitmap(destwidth, destheight, bitmap.config.argb_8888);           bitmap dst = bitmap.createbitmap(bitmapsrc, 0, 0, 100, 100);          // creating new canvas          canvas canvas = new canvas(bitmapdest);         canvas.save();           canvas.rotate(degree, destwidth / 2, destheight / 2);         int offset = (destheight - destwidth) / 2 * ((degree - 180) % 180) / 90;         canvas.translate(offset, -offset);         canvas.drawbitmap(bitmapsrc, 0, 0, null);         canvas.restore();         bitmapsrc.recycle();         bitmapsrc = null;           try {               // output image path sd               outputstream os = new fileoutputstream(new file(makeimagepath()));             bitmapdest.compress(bitmap.compressformat.png, 100, os);              outputstream os2 = new fileoutputstream(new file(makeimagepath()));             bitmapdest.compress(bitmap.compressformat.png, 100, os2);             os.close();             os2.close();            //croppedbitmap.compress(bitmap.compressformat.png, 100, os);         } catch (filenotfoundexception e) {             e.printstacktrace();         }catch(exception e){          }      } 


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -