using (MemoryStream memoryStream = new MemoryStream()){ Image controlImage = new Bitmap(pageImage.Width, pageImage.Height); using (Graphics graphics = Graphics.FromImage(controlImage)) { graphics.Clear(Color.White); graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; pageImage.DrawToBitmap((Bitmap)controlImage, new Rectangle(0, 0, pageImage.Width, pageImage.Height)); } controlImage.Save(memoryStream, ImageFormat.Png); File.WriteAllBytes(originalLocation, memoryStream.ToArray());}
private void PageImage_MouseUp(object sender, MouseEventArgs e){ if (e.Button == MouseButtons.Left) { isDrawing = false; //MemoryStream ms = new MemoryStream(); pageImage.Image?.Dispose(); drawingBitmap.Save("C:\\test.png"); //pageImage.ImageLocation); }}