Rendering an image from an external file

0 votes
12 views
asked Apr 11 by Sebastian
Can I load an image from an external file and render it on the GDI canvas?

1 Answer

0 votes
answered Apr 11 by Ilia Korjoukov (8,120 points)
selected Apr 12 by Ilia Korjoukov
 
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

FAQ questions

Installation and License


Coding


Eye-tracking


EEG Analysis


Visual Stimuli


Runtime and Data Collection


Hardware

...