本文整理汇总了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();
});
});
}
示例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)
{
//.........这里部分代码省略.........