Image from Resource - eto

Hello

I’m building a form with Eto and want to use a bitmap from the assembly resources as a button image.
Accessing the bitmap in winforms is as simple as “Resources.Load” but how can I reference the same bitmap in Eto.
I’ve tried using the below, but it cannot locate the the resource in the assembly (GH). I’ve tried all path combinations too without any luck:

loadButton.Image = Eto.Drawing.Bitmap.FromResource("Resources.Load");

I’ve looked through the assembly and found the correct “path” and also found it via the resourcemanager, but Eto cannot see it…

If I do the following I get an image, but it seems over the top:

loadButton.Image = new Eto.Drawing.Bitmap((byte[])converter.ConvertTo(Resources.Load, typeof(byte[])));

What is the best way to do this?
Thank you!

Hey @thomas.william.lee,

The Bitmap.FromResource loads the file from an embedded resource, not a resources (resx) file. So, if you set a file to embedded resource in your project, you would use something like:

Bitmap.FromResource("MyRootNamespace.Path.To.MyFile.png")

Hope this helps.

1 Like

Thank you @curtisw for the quick reply and explanation. Embedding the resource worked.
Have a nice day!