瀏覽代碼

合并-像素格式转换

zhuyi 2 年之前
父節點
當前提交
35824f4547
共有 1 個文件被更改,包括 9 次插入0 次删除
  1. 9 0
      PDF Office/ViewModels/Dialog/ToolsDialogs/MergeDialogViewModel.cs

+ 9 - 0
PDF Office/ViewModels/Dialog/ToolsDialogs/MergeDialogViewModel.cs

@@ -185,6 +185,15 @@ namespace PDF_Office.ViewModels.Dialog.ToolsDialogs
                 {
                     BitmapSource frame = MergeObjectlist[i].DocThumbnail;
                     byte[] imageData = new byte[frame.PixelWidth * frame.PixelHeight * 4];
+                    if (frame.Format != PixelFormats.Bgra32)
+                    {
+                        FormatConvertedBitmap covert = new FormatConvertedBitmap(frame, PixelFormats.Bgra32, frame.Palette, 0);
+                        covert.CopyPixels(imageData, frame.PixelWidth * 4, 0);
+                    }
+                    else
+                    {
+                        frame.CopyPixels(imageData, frame.PixelWidth * 4, 0);
+                    }
                     frame.CopyPixels(imageData, frame.PixelWidth * 4, 0);
                     result = SaveDoc.InsertPage(0, frame.PixelWidth, frame.PixelHeight, imageData, CPDFDocumentImageMode.CPDFDocumentImageModeScaleToFill);
                     if (!result)