C# 在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
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);