Question

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); ?

Was it helpful?

Solution

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top