Add copyright information to the image

xiaoxiao2021-03-06  113

Bitmap Bitmap = New Bitmap (this.PictureBox2.width, this.picturebox2.height, system.drawing.imaging.pixelformat.format24bpprgb);

/ / Get the canvas according to bitmap

Graphics g = graphics.fromimage (bitmap);

// Empty the canvas and fill it with transparent color

g.clear (color.transparent);

// draw another picture to the canvas

g.drawimage (this.PictureBox1.image, 0,0);

// Write copyright information to the picture.

g.drawstring (this.textbox2.text, new font ("black body", 15), new solidbrush (color.red), New Rectangle (20, 20, 100, 100));

//display

This.PictureBox2.Image = bitmap;

//save Picture

Bitmap.save ("c: //abc.bmp", system.drawing.image.imageformat.bmp);

By the way, click the "Select" button Click the event:

Private void Button1_Click (Object Sender, System.Eventargs E)

{

IF (this.openfiledialog1.showdialog () == DialogResult.ok)

{

IF (this.openfiledialog1.filename.length == 0)

{

MessageBox.show ("Please select the picture", "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 ("Your selected file is not recognizable picture format", "error", messageboxbuttons.ok, messageboxicon.error;

}

Finally

{

fs.close ();

}

}

}

转载请注明原文地址:https://www.9cbs.com/read-126311.html

New Post(0)