Exemplo n.º 1
0
		public static Android.Net.Uri GetImageUri(Context inContext, Android.Graphics.Bitmap inImage)
		{
			MemoryStream bytes = new MemoryStream();
			inImage.Compress(Bitmap.CompressFormat.Jpeg, 100, bytes);
			String path = MediaStore.Images.Media.InsertImage(inContext.ContentResolver, inImage, "Title", "Description");
			if (path == null)
			{
				return null;
			}
			return Android.Net.Uri.Parse(path);
		}
      public static FileInfo SaveBitmap(Context context, Android.Graphics.Bitmap bmp, String folderName, MediaScannerConnection.IOnScanCompletedListener onScanCompleteListener)
      {
         DateTime dateTime = DateTime.Now;
         String fileName = String.Format("IMG_{0}{1}{2}_{3}{4}{5}.jpg", dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second);
         //String fileName =  DateTime.Now.ToString().Replace('/', '-').Replace(':', '-').Replace(' ', '-') + ".jpg";
         FileInfo f = new FileInfo(System.IO.Path.Combine(Android.OS.Environment.ExternalStorageDirectory.ToString(), folderName, fileName));
         if (!f.Directory.Exists)
            f.Directory.Create();

         using (System.IO.FileStream writer = new System.IO.FileStream(
                           f.FullName,
                           System.IO.FileMode.Create))
         {
            bmp.Compress(Android.Graphics.Bitmap.CompressFormat.Jpeg, 90, writer);
         }

         MediaScannerConnection.ScanFile(context, new String[] { f.FullName }, null, onScanCompleteListener);
         return f;
      }
Exemplo n.º 3
0
 public static void Screen2File(Android.Graphics.Bitmap b)
 {
     try{
         using(FileStream fs=new FileStream(screenfile,FileMode.Create)){
             b.Compress(Android.Graphics.Bitmap.CompressFormat.Png,90,fs);
             Console.WriteLine(screenfile);
         }
     }catch(Exception e){Console.Write (e.StackTrace);}
 }