diff options
author | sr55 <[email protected]> | 2017-07-20 19:38:15 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2017-07-20 19:39:02 +0100 |
commit | 6eaa4e3e3bd74dcd56ea3624d91b5af0a9ba12ab (patch) | |
tree | f5e0d38a73611bb50d1b3efd691c4bf9f5e5803b | |
parent | c643347be00539c4526e84a15177a98cd5099c52 (diff) |
WinGui: Simplify the GetPreview code and remove code that was causing the BitMap buffers to incorrectly populate.
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs index 7919086cc..dda3e39c7 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs @@ -292,16 +292,6 @@ namespace HandBrake.ApplicationServices.Interop }
};
- // Sanitize the input.
- Geometry resultGeometry = AnamorphicFactory.CreateGeometry(settings, new SourceVideoInfo(new Size(title.Geometry.Width, title.Geometry.Height), new Size(title.Geometry.PAR.Num, title.Geometry.PAR.Den)));
- int width = resultGeometry.Width * resultGeometry.PAR.Num / resultGeometry.PAR.Den;
- int height = resultGeometry.Height;
-
- uiGeometry.geometry.width = width;
- uiGeometry.geometry.height = height;
- uiGeometry.geometry.par.num = settings.PixelAspectX;
- uiGeometry.geometry.par.den = settings.PixelAspectY;
-
// Fetch the image data from LibHb
IntPtr resultingImageStuct = HBFunctions.hb_get_preview2(this.hbHandle, settings.TitleNumber, previewNumber, ref uiGeometry, 0);
hb_image_s image = InteropUtilities.ToStructureFromPtr<hb_image_s>(resultingImageStuct);
@@ -314,8 +304,9 @@ namespace HandBrake.ApplicationServices.Interop byte[] managedBuffer = new byte[imageBufferSize];
Marshal.Copy(image.plane[0].data, managedBuffer, 0, imageBufferSize);
- var bitmap = new Bitmap(width, height);
- BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format32bppRgb);
+ var bitmap = new Bitmap(image.width, image.height);
+
+ BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, image.width, image.height), ImageLockMode.WriteOnly, PixelFormat.Format32bppRgb);
IntPtr ptr = bitmapData.Scan0; // Pointer to the first pixel.
for (int i = 0; i < image.height; i++)
@@ -323,7 +314,7 @@ namespace HandBrake.ApplicationServices.Interop try
{
Marshal.Copy(managedBuffer, i * stride_width, ptr, stride_width);
- ptr = IntPtr.Add(ptr, width * 4);
+ ptr = IntPtr.Add(ptr, image.width * 4);
}
catch (Exception exc)
{
|