//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();
					});
				});
			}
//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)
						{
							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 OnScanCompletedListenerAnonymousInnerClassHelper2(this));

						runOnUiThread(() =>
						{
							Toast.makeTextuniquetempvar.show();
						});
					});
				}
			}