当前位置: 首页>>代码示例>>C#>>正文


C# Bitmap.CompressAsync方法代码示例

本文整理汇总了C#中Android.Graphics.Bitmap.CompressAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Bitmap.CompressAsync方法的具体用法?C# Bitmap.CompressAsync怎么用?C# Bitmap.CompressAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android.Graphics.Bitmap的用法示例。


在下文中一共展示了Bitmap.CompressAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExportBitmapAsJPG

		public async void ExportBitmapAsJPG(Bitmap bitmap, int index)
		{
			string sdCardPath = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;
			string name = "_" + index.ToString () + ".jpg";
			string filePath = System.IO.Path.Combine(sdCardPath, name);
			var stream = new System.IO.FileStream(filePath, System.IO.FileMode.Create);

			await bitmap.CompressAsync (Bitmap.CompressFormat.Jpeg, 30, stream);
			stream.Close ();
		}
开发者ID:dimalavoryk,项目名称:MyCity,代码行数:10,代码来源:Saving.cs

示例2: UploadPhoto

        public static async Task<bool> UploadPhoto(string listName, string imageName, Bitmap bitmap)
        {
            bool success = false;
            try
            {
                string requestUrl = string.Format("{0}/_api/web/GetFolderByServerRelativeUrl('{1}')/Files/add(url='{2}',overwrite=true)", Constants.SHAREPOINT_URL + Constants.SHAREPOINT_SITE_PATH, listName, imageName);
                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(requestUrl);
                request.Method = "POST";
                request.Accept = "image/png, image/svg+xml, image/*;q=0.8, */*;q=0.5";
                request.ContentType = "application/octet-stream";
                request.Headers.Add("Authorization", "Bearer " + App.Token);
                Stream requestStream = request.GetRequestStream();
                MemoryStream outputStearm = new MemoryStream();
                await bitmap.CompressAsync(Bitmap.CompressFormat.Jpeg, 100, outputStearm);
                byte[] bytes = outputStearm.ToArray();
                await requestStream.WriteAsync(bytes, 0, bytes.Length);

                using (HttpWebResponse response = await request.GetResponseAsync() as HttpWebResponse)
                {
                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        success = true;
                    }
                }
            }
            catch (Exception)
            {
                success = false;
            }

            return success;
        }
开发者ID:rajendra1809,项目名称:Property-Inspection-Code-Sample,代码行数:32,代码来源:ListClient.cs

示例3: exportBitmapAsPNG

		protected async void exportBitmapAsPNG(Bitmap bitmap, string path)
		{
			using (var stream =  new FileStream(path, FileMode.Create))
			{
				await bitmap.CompressAsync(Bitmap.CompressFormat.Png, 100, stream);
			}
		}
开发者ID:Armoken,项目名称:Learning,代码行数:7,代码来源:NewContactEditScreen.cs


注:本文中的Android.Graphics.Bitmap.CompressAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。