1. 程式人生 > >Canvas資料轉圖片

Canvas資料轉圖片

   System.out.println("imagepath="+imagepath);
   File dir=new File(imagepath);
   if(!dir.exists()){
    dir.mkdirs();
   }
   String filename=new Date().getTime()+".png";
   File decFile = new File(imagepath+"\\"+filename);
   String dd=decFile.getAbsolutePath();
   if(decFile.exists()){
    decFile.delete();
   }
   decFile.createNewFile();
   FileOutputStream ops = new FileOutputStream(decFile);
   ops.write(imgBytes, 0, imgBytes.length);
   ops.flush();
   ops.close();
  } catch (IOException e) {
   e.printStackTrace();
  }