<SpecificVersion>False</SpecificVersion>\r
<HintPath>..\libraries\json\Newtonsoft.Json.dll</HintPath>\r
</Reference>\r
- <Reference Include="PresentationCore" />\r
- <Reference Include="PresentationFramework" />\r
<Reference Include="System" />\r
<Reference Include="System.ComponentModel.DataAnnotations" />\r
<Reference Include="System.Core">\r
<Reference Include="System.Management" />\r
<Reference Include="System.Runtime.Serialization" />\r
<Reference Include="System.ServiceModel" />\r
- <Reference Include="System.Windows.Forms" />\r
<Reference Include="System.Xaml" />\r
<Reference Include="System.Xml.Linq">\r
<RequiredTargetFramework>3.5</RequiredTargetFramework>\r
</Reference>\r
<Reference Include="System.Data" />\r
<Reference Include="System.Xml" />\r
- <Reference Include="WindowsBase" />\r
</ItemGroup>\r
<ItemGroup>\r
<Compile Include="Attributes\ShortName.cs" />\r
using System.Runtime.ExceptionServices;\r
using System.Runtime.InteropServices;\r
using System.Timers;\r
- using System.Windows.Media.Imaging;\r
\r
using HandBrake.ApplicationServices.Interop.EventArgs;\r
using HandBrake.ApplicationServices.Interop.Factories;\r
/// An image with the requested preview.\r
/// </returns>\r
[HandleProcessCorruptedStateExceptions]\r
- public BitmapImage GetPreview(PreviewSettings settings, int previewNumber)\r
+ public Bitmap GetPreview(PreviewSettings settings, int previewNumber)\r
{\r
SourceTitle title = this.Titles.TitleList.FirstOrDefault(t => t.Index == settings.TitleNumber);\r
\r
IntPtr nativeJobPtrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));\r
Marshal.WriteIntPtr(nativeJobPtrPtr, resultingImageStuct);\r
HBFunctions.hb_image_close(nativeJobPtrPtr);\r
- Marshal.FreeHGlobal(nativeJobPtrPtr); \r
+ Marshal.FreeHGlobal(nativeJobPtrPtr);\r
\r
- // Create a Bitmap Image for display.\r
- using (var memoryStream = new MemoryStream())\r
- {\r
- try\r
- {\r
- bitmap.Save(memoryStream, ImageFormat.Bmp);\r
- }\r
- finally\r
- {\r
- bitmap.Dispose();\r
- }\r
-\r
- var wpfBitmap = new BitmapImage();\r
- wpfBitmap.BeginInit();\r
- wpfBitmap.CacheOption = BitmapCacheOption.OnLoad;\r
- wpfBitmap.StreamSource = memoryStream;\r
- wpfBitmap.EndInit();\r
- wpfBitmap.Freeze();\r
-\r
- return wpfBitmap;\r
- }\r
+ return bitmap;\r
}\r
\r
/// <summary>\r
namespace HandBrake.ApplicationServices.Interop.Interfaces\r
{\r
using System;\r
- using System.Windows.Media.Imaging;\r
+ using System.Drawing;\r
\r
using HandBrake.ApplicationServices.Interop.EventArgs;\r
using HandBrake.ApplicationServices.Interop.Json.Encode;\r
/// <returns>\r
/// An image with the requested preview.\r
/// </returns>\r
- BitmapImage GetPreview(PreviewSettings job, int previewNumber);\r
+ Bitmap GetPreview(PreviewSettings job, int previewNumber);\r
\r
/// <summary>\r
/// Pauses the current encode.\r
<Compile Include="Services\UserSettingService.cs" />\r
<Compile Include="Startup\StartupOptions.cs" />\r
<Compile Include="Utilities\AppcastReader.cs" />\r
+ <Compile Include="Utilities\BitmapUtilities.cs" />\r
<Compile Include="Utilities\DelayedActionProcessor.cs" />\r
<Compile Include="Utilities\DPIAwareness.cs" />\r
<Compile Include="Utilities\DriveUtilities.cs" />\r
using HandBrakeWPF.Services.Scan.EventArgs;
using HandBrakeWPF.Services.Scan.Interfaces;
using HandBrakeWPF.Services.Scan.Model;
+ using HandBrakeWPF.Utilities;
using Chapter = HandBrakeWPF.Services.Scan.Model.Chapter;
using ScanProgressEventArgs = HandBrake.ApplicationServices.Interop.EventArgs.ScanProgressEventArgs;
PixelAspectY = job.PixelAspectY
};
- bitmapImage = this.instance.GetPreview(settings, preview);
+ bitmapImage = BitmapUtilities.ConvertToBitmapImage(this.instance.GetPreview(settings, preview));
}
catch (AccessViolationException e)
{
--- /dev/null
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="BitmapUtilities.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Defines the BitmapUtilities type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Utilities
+{
+ using System.Drawing;
+ using System.Drawing.Imaging;
+ using System.IO;
+ using System.Windows.Media.Imaging;
+
+ /// <summary>
+ /// The bitmap utilities.
+ /// </summary>
+ public class BitmapUtilities
+ {
+ /// <summary>
+ /// Convert a Bitmap to a BitmapImagetype.
+ /// </summary>
+ /// <param name="bitmap">
+ /// The bitmap.
+ /// </param>
+ /// <returns>
+ /// The <see cref="BitmapImage"/>.
+ /// </returns>
+ public static BitmapImage ConvertToBitmapImage(Bitmap bitmap)
+ {
+ // Create a Bitmap Image for display.
+ using (var memoryStream = new MemoryStream())
+ {
+ try
+ {
+ bitmap.Save(memoryStream, ImageFormat.Bmp);
+ }
+ finally
+ {
+ bitmap.Dispose();
+ }
+
+ var wpfBitmap = new BitmapImage();
+ wpfBitmap.BeginInit();
+ wpfBitmap.CacheOption = BitmapCacheOption.OnLoad;
+ wpfBitmap.StreamSource = memoryStream;
+ wpfBitmap.EndInit();
+ wpfBitmap.Freeze();
+
+ return wpfBitmap;
+ }
+ }
+ }
+}