I don't understand this issue. Because this usually worked till now. This method is reaction on click for saving image on pictureBox which is called canvas. I load the Image on canvas and then do some edits. Then I want save the image. If I click on the printScreenButton before loading image it works, but when I load the image it stops working. Where could be the problem?
private void printScreenButton_Click(object sender, EventArgs e)
{
canvas.Image.Save("name.png", System.Drawing.Imaging.ImageFormat.Png);
}
Edit:
Work == file called name.png is created
Doesn't work == file called name.png isn't created
Code for drawing an image == putting on picture box
` private void drawTransformedBitmap(Matrix transformationMatrix)
{
Graphics g = Graphics.FromImage(canvasBitmapShow); //prepare graphics
if (antialiasing)
{
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear;
}
else
{
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
}
g.Clear(Color.White); //clear canvas
g.Transform.Reset(); //clear transformations
g.Transform = transformationMatrix; //set transformations from transformationMatrix
g.DrawImage(canvasBitmapTarget, 0, 0); //draw from Bitmap called canvasBitmapTarget
canvas.Invalidate(); //refresh canvas
}`
Initialization at the begining:
canvasBitmapShow = new Bitmap(canvas.Width, canvas.Height);
canvasBitmapSource = new Bitmap(canvas.Width, canvas.Height);
canvasBitmapTarget = new Bitmap(canvas.Width, canvas.Height);
canvasBitmapBackup = new Bitmap(canvas.Width, canvas.Height);
canvas.Image = canvasBitmapShow; //set the Image