本文整理汇总了C#中Android.Compress方法的典型用法代码示例。如果您正苦于以下问题:C# Android.Compress方法的具体用法?C# Android.Compress怎么用?C# Android.Compress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android
的用法示例。
在下文中一共展示了Android.Compress方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetImageUri
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);
}
示例2: SaveBitmap
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;
}
示例3: Screen2File
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);}
}