From: sr55 Date: Thu, 20 Jul 2017 18:38:15 +0000 (+0100) Subject: WinGui: Simplify the GetPreview code and remove code that was causing the BitMap... X-Git-Tag: 1.1.0~461 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6eaa4e3e3bd74dcd56ea3624d91b5af0a9ba12ab;p=handbrake WinGui: Simplify the GetPreview code and remove code that was causing the BitMap buffers to incorrectly populate. --- 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(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) {