Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在C中将位图转换为可写位图#_C#_Wpf - Fatal编程技术网

C# 在C中将位图转换为可写位图#

C# 在C中将位图转换为可写位图#,c#,wpf,C#,Wpf,我在应用程序中使用c#。我已将位图直接转换为可写位图。 我不想将位图转换为其他格式 pdftron.PDF.PDFDraw draw = new pdftron.PDF.PDFDraw(); using (System.Drawing.Bitmap gdiBitmap = draw.GetBitmap(_pdfDoc.GetPage(page))) { // System.Drawing.Bitmap myBitmap = Bit

我在应用程序中使用c#。我已将位图直接转换为可写位图。 我不想将位图转换为其他格式

    pdftron.PDF.PDFDraw draw = new pdftron.PDF.PDFDraw();
        using (System.Drawing.Bitmap gdiBitmap = draw.GetBitmap(_pdfDoc.GetPage(page)))
        {

            // System.Drawing.Bitmap myBitmap = BitmapFromWriteableBitmap(target);
            using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(gdiBitmap))
            {
                System.Drawing.Color customColor = System.Drawing.Color.FromArgb(50, System.Drawing.Color.Red);
                System.Drawing.SolidBrush shadowBrush = new System.Drawing.SolidBrush(customColor);
                g.FillRectangles(shadowBrush, new System.Drawing.Rectangle[] { rectangle });
            }
}

现在我必须将其转换为可写位图。

首先,您需要从
位图创建
位图源代码,然后您可以从中创建
可写位图

System.Windows.Media.Imaging.BitmapSource bitmapSource =
  System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
  gdiBitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty,
  System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
System.Windows.Media.Imaging.WriteableBitmap writeableBitmap = new System.Windows.Media.Imaging.WriteableBitmap(bitmapSource);