Saint
Saint

Reputation: 5469

How to use bitmap from resources instead of the file (migradoc)?

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

Upvotes: 1

Views: 2042

Answers (1)

Romano Zumbé
Romano Zumbé

Reputation: 8079

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

Upvotes: 3

Related Questions