| // Create a bitmap Bitmap bitmap = new Bitmap (this. picturebox2.width, this. picturebox2.height, system. Drawing. imaging. pixelformat. format24bpprgb ); // Obtain the canvas Based on the bitmap Graphics G = graphics. fromimage (Bitmap ); // Clear the canvas and fill it with transparent colors G. Clear (color. Transparent ); // Draw another image to the canvas G. drawimage (this. picturebox1.image, 0, 0 ); // Write the copyright information to the image. G. drawstring (this. textbox2.text, new font ("", 15), new solidbrush (color. Red), new rectangle (20, 20, 100,100 )); // Display This. picturebox2.image = bitmap; // Save the image Bitmap. Save ("C: // abc.bmp", system. Drawing. imaging. imageformat. BMP ); By the way, the "select" button click event program: Private void button#click (Object sender, system. eventargs E) { If (this. openfiledialog1.showdialog () = dialogresult. OK) { If (this. openfiledialog1.filename. Length = 0) { MessageBox. Show ("select image", "error", messageboxbuttons. OK, messageboxicon. Error ); Return; } This. textbox1.text = This. openfiledialog1.filename; Filestream FS = new filestream (this. openfiledialog1.filename, filemode. Open, fileaccess. Read ); Try { This. picturebox1.image = image. fromstream (FS ); } Catch (exception) { MessageBox. Show ("the file you selected is not an identifiable image format", "error", messageboxbuttons. OK, messageboxicon. Error ); } Finally { FS. Close (); } } } |