Unfortunately, Solution 1 really bad, no matter if it works or not. It suggests to do thing much more complex than they have to be.
Your problem was completely different: it was using
PictureBox
, which is a control, not an image.
First of all, the whole imaging library has nothing to do with controls. It you do, you violate elementary isolation between UI and anything, imaging, for example. But this control is especially bad, because too many beginner try to stick it where it is no good. The rule of thumb is: never ever use it at all.
And of course, there is no such method. You need to work with either
Bitmap
or
BitmapData
. No need to go as far as to create and
UnmanagedImage
:
http://www.aforgenet.com/framework/docs/html/1cc59f9a-2db9-e5e3-76b2-2d9bc84eab2d.htm[
^].
In your case, I would simply use
Bitmap
, to represent the image.
To help yourself to forget that haunting
PictureBox
, please see my past answers:
How do I clear a panel from old drawing[
^],
draw a rectangle in C#[
^],
Append a picture within picturebox[
^],
Drawing Lines between mdi child forms[
^],
capture the drawing on a panel[
^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[
^],
How to speed up my vb.net application?[
^].
—SA