Pictures of various rotations, changes in size

Source: Internet
Author: User
Tags rotate image

1, all kinds of rotation, change the size

Note: To first add paint-related

Using

Reference.

//

Rotate the image to the right

90

° Code is as follows

:

private void Form1_paint (object sender, System.Windows.Forms.PaintEventArgs e)

{

Graphics g = e.graphics;

Bitmap bmp = New Bitmap ("rama.jpg");//

Loading images

G.fillrectangle (Brushes.white, this. ClientRectangle);//

Fill the form with white background

Point[] Destinationpoints = {

New Point (0),//destination to Upper-left point of original

New Point (+),//destination for Upper-right point of original

New Point (0, 0)}; Destination for Lower-left Point of original

G.drawimage (BMP, Destinationpoints);

}

//

Rotate image

180

° Code is as follows

:

private void Form1_paint (object sender, System.Windows.Forms.PaintEventArgs e)

{

Graphics g = e.graphics;

Bitmap bmp = New Bitmap ("rama.jpg");

G.fillrectangle (Brushes.white, this. ClientRectangle);

Point[] Destinationpoints = {

New Point (0, +),//destination for Upper-left point of original

New Point (+),//destination for Upper-right point of original

New Point (0, 0)}; Destination for Lower-left Point of original

G.drawimage (BMP, Destinationpoints);

}

//

Image Shear Code

:

private void Form1_paint (object sender, System.Windows.Forms.PaintEventArgs e)

{

Graphics g = e.graphics;

Bitmap bmp = New Bitmap ("rama.jpg");

G.fillrectangle (Brushes.white, this. ClientRectangle);

Point[] Destinationpoints = {

New Point (0, 0),//destination to Upper-left point of original

New Point (0),//destination to Upper-right point of original

New Point (};//) destination to Lower-left point of original

G.drawimage (BMP, Destinationpoints);

}

//

Image interception

:

private void Form1_paint (object sender, System.Windows.Forms.PaintEventArgs e)

{

2

Graphics g = e.graphics;

Bitmap bmp = New Bitmap ("rama.jpg");

G.fillrectangle (Brushes.white, this. ClientRectangle);

Rectangle sr = new Rectangle (80, 60, 400, 400);//

The rectangular area to intercept

Rectangle dr = new Rectangle (0, 0, 200, 200);//

To display to

Form

The rectangular area

G.drawimage (BMP, Dr, Sr, GraphicsUnit.Pixel);

}

//

Change image size

:

private void Form1_paint (object sender, System.Windows.Forms.PaintEventArgs e)

{

Graphics g = e.graphics;

Bitmap bmp = New Bitmap ("rama.jpg");

G.fillrectangle (Brushes.white, this. ClientRectangle);

int width = bmp. Width;

int height = bmp. Height;

//

Change image size using low-quality mode

G.interpolationmode = Interpolationmode.nearestneighbor;

G.drawimage (BMP, New Rectangle (Ten, ten, +),//Source Rectangle

New Rectangle (0, 0, width, height),//Destination Rectangle

GraphicsUnit.Pixel);

//

Use high-quality mode

g.compositingquality = Compositingquality.highspeed;

G.interpolationmode = Interpolationmode.highqualitybicubic;

G.drawimage (

Bmp

New Rectangle (130, 10, 120, 120),

New Rectangle (0, 0, width, height),

GraphicsUnit.Pixel);

}

//

Set the resolution of an image

:

private void Form1_paint (object sender, System.Windows.Forms.PaintEventArgs e)

{

Graphics g = e.graphics;

Bitmap bmp = New Bitmap ("rama.jpg");

G.fillrectangle (Brushes.white, this. ClientRectangle);

Bmp. Setresolution (300f, 300f);

G.drawimage (BMP, 0, 0);

Bmp. Setresolution (1200f, 1200f);

G.drawimage (BMP, 180, 0);

}

//

Use

Gdi+

Drawing

3

private void Form1_paint (object sender, System.Windows.Forms.PaintEventArgs e)

{

Graphics gForm = e.graphics;

Gform.fillrectangle (Brushes.white, this. ClientRectangle);

for (int i = 1; I <= 7; ++i)

{

//

Draw an orange rectangle on the form

Rectangle r = new Rectangle (i*40-15, 0, 15,

This. Clientrectangle.height);

Gform.fillrectangle (Brushes.orange, R);

}

//

In memory, create a

Bitmap

and set

CompositingMode

Bitmap bmp = new Bitmap (260, 260,

SYSTEM.DRAWING.IMAGING.PIXELFORMAT.FORMAT32BPPARGB);

Graphics gbmp = graphics.fromimage (BMP);

Gbmp.compositingmode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;

//

Create a

Alpha

The red area

//

and draw it in the memory bitmap.

Color red = Color.FromArgb (0x60, 0xff, 0, 0);

Brush Redbrush = new SolidBrush (red);

Gbmp.fillellipse (Redbrush, 70, 70, 160, 160);

//

Create a

Alpha

The green area

Color green = Color.FromArgb (0x40, 0, 0xFF, 0);

Brush Greenbrush = new SolidBrush (green);

Gbmp.fillrectangle (Greenbrush, 10, 10, 140, 140);

//

Draw a bitmap on a form

Now draw the bitmap in our window

Gform.drawimage (BMP, +, BMP). Width, BMP. Height);

//

Clean up resources

Bmp. Dispose ();

Gbmp.dispose ();

Redbrush.dispose ();

Greenbrush.dispose ();

}

Pipe plugging equipment Hertz Car Rental Translation Parts
Baidu Encyclopedia to share: QQ space Sina Weibo Renren networkEvaluation documents: /251 Download coupons to join VIP, free download this articleCopy | Search | Translation | Encyclopedia |

Rotate, change size of picture

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.