【问题标题】:How to use bitmap from resources instead of the file (migradoc)?如何使用资源中的位图而不是文件(migradoc)?
【发布时间】:2013-06-14 08:32:58
【问题描述】:

如何使用来自资源的位图,而不是 MigraDoc.DocumentObjectModel.Tables.Cell 类中的物理图像文件

在方法public Image AddImage(string fileName); ?

【问题讨论】:

    标签: c# winforms image pdfsharp migradoc


    【解决方案1】:

    如果您已将名为“myImage”的图像添加到项目资源中,请使用以下代码:

    Properties.Resources.myImage
    

    在您的示例中调整参数:

    public Image AddImage(Image img);
    

    然后这样称呼它:

    AddImage(Properties.Resources.myImage);
    

    如果需要传递文件名,只需先将图像写入文件(可能写入临时目录):

        string fileName = "C:\\image.jpg";
    
        ((Bitmap)Properties.Resources.myImage).Save(fileName, ImageFormat.Jpeg);
    
        AddImage(fileName);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-04-06
      • 2022-01-20
      • 2012-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多