简体   繁体   English

如何创建一个iTextSharp.text.Image对象startng到System.Drawing.Bitmap对象?

[英]How to create a iTextSharp.text.Image object startng to a System.Drawing.Bitmap object?

I am pretty new in iTextSharp (the C# version of iText ): 我是iTextSharpiText的C#版本)的新手:

I have something like this: 我有这样的事情:

System.Drawing.Bitmap bitmap = (System.Drawing.Bitmap)ChartHelper.GetPdfChart((int)currentVuln.UrgencyRating * 10);

iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(bitmap);

vulnerabilityDetailsTable.AddCell(new PdfPCell(img) { Border = PdfPCell.RIGHT_BORDER, BorderColor = new BaseColor(79, 129, 189), BorderWidth = 1, Padding = 5, MinimumHeight = 30, PaddingTop = 10 });  

As you can see I have classic System.Drawing.Bitmap immage named bitmap and I want put it inside a cell of a PDF document table. 正如你所看到的,我有经典的System.Drawing.Bitmap immage命名为bitmap ,我希望将它放在PDF文档表的单元格中。

The problem is that this line is signed as error: 问题是此行被签名为错误:

iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(bitmap);

The error is: 错误是:

Error 75 The best overloaded method match for 'iTextSharp.text.Image.GetInstance(iTextSharp.text.Image)' has some invalid arguments c:\\Develop\\EarlyWarning\\public\\Implementazione\\Ver2\\PdfReport\\PdfVulnerability.cs 120 27 PdfReport 错误75'iTextSharp.text.Image.GetInstance(iTextSharp.text.Image)'的最佳重载方法匹配有一些无效的参数c:\\ Develop \\ EarlyWarning \\ public \\ Implementazione \\ Ver2 \\ PdfReport \\ PdfVulnerability.cs 120 27 PdfReport

So I think that I need to obtain an iTextSharp.text.Image object from a classic System.Drawing.Bitmap object. 所以我认为我需要从经典的System.Drawing.Bitmap对象中获取iTextSharp.text.Image对象。

What can I do to do it? 我该怎么办呢? I am going crazy trying to do it. 我疯狂地试图去做。

Tnx TNX

There are no overloads that take just a System.Drawing.Image . 没有重载只需要System.Drawing.Image You need to used one of these: 你需要使用其中一个:

GetInstance(System.Drawing.Image image, BaseColor color)
GetInstance(System.Drawing.Image image, BaseColor color, bool forceBW)
GetInstance(System.Drawing.Image image, System.Drawing.Imaging.ImageFormat format)

The first one is probably the best choice and I'm 99% sure you can pass null for the color parameter. 第一个可能是最好的选择,我99%肯定你可以为color参数传递null

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将iTextSharp.text.Image转换回System.Drawing.Image - Converting iTextSharp.text.Image back to System.Drawing.Image 从System.Drawing.Image创建iTextSharp.text.Image [GetInstance重载不可用] - Create an iTextSharp.text.Image from System.Drawing.Image [GetInstance overload not available] 如何从System.Drawing.Bitmap对象提取原始图像流? - How can I extract the original image stream from a System.Drawing.Bitmap object? 如何从嵌入式Uri资源(png图像)加载System.Drawing.Bitmap对象? - How to load a System.Drawing.Bitmap object from an embedded Uri resource (png image)? 如何将12位图像加载到System.Drawing.Bitmap中? - How to load 12 bit image into System.Drawing.Bitmap? 如何从System.Drawing.Bitmap显示图像类型 - How to display Image type from System.Drawing.Bitmap 从System.Drawing.Bitmap对象转换为cv :: Mat时,位图变形 - Bitmap gets mangled when I converted from System.Drawing.Bitmap object to cv::Mat 什么时候System.Drawing.Bitmap不是System.Drawing.Bitmap? - When is System.Drawing.Bitmap not System.Drawing.Bitmap? 从GTK访问System.Drawing.Bitmap #Thread抛出Object目前在其他地方使用异常 - Accessing System.Drawing.Bitmap from GTK# Thread throws Object Currently in use elsewhere exception 从 System.Drawing.Bitmap 创建 google.cloud.vision.v1.image - Create google.cloud.vision.v1.image from System.Drawing.Bitmap
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM