The code is very simple: I Press the button, the picture is loaded into the PictureBox.
private void button1_Click(object sender, EventArgs e)
{
using (FileStream stream = File.OpenRead(FullName))
{
pictureBox1.Image = (Bitmap)Bitmap.FromStream(stream).Clone();
stream.Close();
stream.Dispose();
}
}
But when from other function\events I use Graphics on PictureBox'e, it swears that there is not enough memory on Graphics.FromImage. No matter what I do with this schedule. Example:
using (Graphics g = Graphics.FromImage(pictureBox1.Image))
{
g.Clear(Color.FromArgb(0, 255, 255, 255));
pictureBox1.Invalidate();
}
The question is, why can I do anything I want with Graphics before uploading a picture to the PictureBox:cut, fill,draw; but after uploading a picture I can't? p.s. Picture tried different sizes. The same picture works before uploading(it was already in the default pictureBox) and does not work after uploading to the pictureBox. Walked quite a lot of forums on this subject, but my case(or the most similar case) is not found.