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


C# Image.close方法代码示例

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


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

示例1: save

//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: void save(final android.media.Image image, String filename)
			internal virtual void save(Image image, string filename)
			{

				File dir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).AbsolutePath + "/Camera/");
				if (!dir.exists())
				{
					dir.mkdirs();
				}

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.io.File file = new java.io.File(dir, filename);
				File file = new File(dir, filename);

				outerInstance.mBackgroundHandler.post(() =>
				{
					ByteBuffer buffer = image.Planes[0].Buffer;
					sbyte[] bytes = new sbyte[buffer.remaining()];
					buffer.get(bytes);
					System.IO.FileStream output = null;
					try
					{
						output = new System.IO.FileStream(file, System.IO.FileMode.Create, System.IO.FileAccess.Write);
						output.Write(bytes, 0, bytes.Length);
					}
					catch (IOException e)
					{
						Console.WriteLine(e.ToString());
						Console.Write(e.StackTrace);
					}
					finally
					{
						image.close();
						if (null != output)
						{
							try
							{
								output.Close();
							}
							catch (IOException e)
							{
								Console.WriteLine(e.ToString());
								Console.Write(e.StackTrace);
							}
						}
					}

					MediaScannerConnection.scanFile(outerInstance, new string[]{file.AbsolutePath}, null, new OnScanCompletedListenerAnonymousInnerClassHelper(this));

					runOnUiThread(() =>
					{
						Toast.makeTextuniquetempvar.show();
					});
				});
			}
开发者ID:moljac,项目名称:Samples.Data.Porting,代码行数:56,代码来源:Sample_YUV.cs

示例2: save

//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: void save(final android.media.Image image, String filename)
			internal virtual void save(Image image, string filename)
			{

				File dir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).AbsolutePath + "/Camera/");
				if (!dir.exists())
				{
					dir.mkdirs();
				}
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.io.File file = new java.io.File(dir, filename);
				File file = new File(dir, filename);

				if (image.Format == ImageFormat.RAW_SENSOR)
				{
					SCaptureResult result = null;
					try
					{
						result = outerInstance.mCaptureResultQueue.take();
					}
					catch (InterruptedException e)
					{
						Console.WriteLine(e.ToString());
						Console.Write(e.StackTrace);
					}

					try
					{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final com.samsung.android.sdk.camera.SDngCreator dngCreator = new com.samsung.android.sdk.camera.SDngCreator(mCharacteristics, result);
						SDngCreator dngCreator = new SDngCreator(outerInstance.mCharacteristics, result);
						dngCreator.Orientation = DNG_ORIENTATION.get(outerInstance.JpegOrientation);

						(new Handler(Looper.myLooper())).post(() =>
						{
							ByteBuffer buffer = image.Planes[0].Buffer;
							sbyte[] bytes = new sbyte[buffer.remaining()];
							buffer.get(bytes);
							System.IO.FileStream output = null;
							try
							{
								output = new System.IO.FileStream(file, System.IO.FileMode.Create, System.IO.FileAccess.Write);
								dngCreator.writeImage(output, image);
							}
							catch (IOException e)
							{
								Console.WriteLine(e.ToString());
								Console.Write(e.StackTrace);
							}
							finally
							{
								image.close();
								dngCreator.close();
								if (null != output)
								{
									try
									{
										output.Close();
									}
									catch (IOException e)
									{
										Console.WriteLine(e.ToString());
										Console.Write(e.StackTrace);
									}
								}
							}

							MediaScannerConnection.scanFile(outerInstance, new string[]{file.AbsolutePath}, null, new OnScanCompletedListenerAnonymousInnerClassHelper(this));

							runOnUiThread(() =>
							{
								Toast.makeTextuniquetempvar.show();
							});
						});
					}
					catch (System.ArgumentException e)
					{
						Console.WriteLine(e.ToString());
						Console.Write(e.StackTrace);
						outerInstance.showAlertDialog("Fail to save DNG file.", false);
						image.close();
						return;
					}
				}
				else
				{
					(new Handler(Looper.myLooper())).post(() =>
					{
						ByteBuffer buffer = image.Planes[0].Buffer;
						sbyte[] bytes = new sbyte[buffer.remaining()];
						buffer.get(bytes);
						System.IO.FileStream output = null;
						try
						{
							output = new System.IO.FileStream(file, System.IO.FileMode.Create, System.IO.FileAccess.Write);
							output.Write(bytes, 0, bytes.Length);
						}
						catch (IOException e)
						{
//.........这里部分代码省略.........
开发者ID:moljac,项目名称:Samples.Data.Porting,代码行数:101,代码来源:Sample_Single.cs


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