Вопрос

How to use e.g. bitmap from resources instead of physical image file in class MigraDoc.DocumentObjectModel.Tables.Cell

in method public Image AddImage(string fileName); ?

Это было полезно?

Решение

If you've added an image with the name "myImage" to your projects resources use this code:

Properties.Resources.myImage

In your example adjust the parameter:

public Image AddImage(Image img);

And call it like this:

AddImage(Properties.Resources.myImage);

If it is required to pass a filename just write the Image to a file first (perhaps to the temp directory):

    string fileName = "C:\\image.jpg";

    ((Bitmap)Properties.Resources.myImage).Save(fileName, ImageFormat.Jpeg);

    AddImage(fileName);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top