0 votes
394 views
by
Can I load an image from an external file and render it on the GDI canvas?

1 Answer

0 votes
by (14.5k points)
selected by
 
Best answer

The GDI canvas element supports all GDI+ drawing functions from System.Drawing namespace in .NET, including the DrawImage() method, which is usually used for images. However, this function fails, when is called by a remoting (IPC) application, as EventIDE. If you call it in the snippets, you will get a runtime error "Remoting connot find field 'nativeImage' on type 'System.Drawing.Image'"

Fortunately, there is a workaround. Instead of using the DrawImage() method, you can render your image as a fill texture for a rectangle.See the following example:

Bitmap MyImage = (Bitmap) Image.FromFile(@"C:\Images0\MyImage001.bmp");
using (TextureBrush brush = new TextureBrush(MyImage, WrapMode.Tile))
    {    
    GraphicsClass.FillRectangle(brush, 0, 0, MyImage.Width, MyImage.Height);
    }

 

 

Welcome to EventIDE Q&A forum where you can ask questions about EventIDE software and receive answers from other members of the community

Categories

FAQ questions

Installation and License


Coding


Eye-tracking


EEG Analysis


Visual Stimuli


Runtime and Data Collection


Hardware

...