Home > Net >  If multiples can be rotated 90 degrees, the Angle of the other images are smaller, how to solve
If multiples can be rotated 90 degrees, the Angle of the other images are smaller, how to solve

Time:09-23

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
Using System. Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
Using System. Drawing. Drawing2D;
Using System. Drawing. Imaging;

The namespace WindowsFormsApp9
{
Public partial class Form1: Form
{
Public _click ()
{
InitializeComponent();
GraphicsPath path=new GraphicsPath ();
Path. AddEllipse (this) for the) ClientRectangle);
This. For. Region=new Region (path);
//bezel Settings
This. For. FlatStyle=FlatStyle. Flat;
//this. For. FlatAppearance. BorderColor=this.. For the BackColor;
This. For. FlatAppearance. BorderSize=0;


GraphicsPath path1=new GraphicsPath ();
Path1. AddEllipse (enclosing button2. ClientRectangle);
This. Button2. Region=new Region (path1);
//bezel Settings
This. Button2. FlatStyle=FlatStyle. Flat;
//this. Button2. FlatAppearance. BorderColor=this. Button2. BackColor;
Enclosing button2. FlatAppearance. BorderSize=0;

GraphicsPath path2=new GraphicsPath ();
Path2. AddEllipse (enclosing button3. ClientRectangle);
This. Button3. Region=new Region (path2);
//bezel Settings
This. Button3. FlatStyle=FlatStyle. Flat;
Enclosing button3. FlatAppearance. BorderSize=0;
Button3. BackColor=Color. Transparent;



}

Private void button2_Click (object sender, EventArgs e)
{
MessageBox. Show (" ", "hello");
}

Private void button1_Click (object sender, EventArgs e)
{
MessageBox. Show (" ", "welcome");
}

Private void button4_Click (object sender, EventArgs e)
{
This. For the BackgroundImage=RotateImg2 (this) for the BackgroundImage, 90, enclosing for);
}
Public Image RotateImg2 (Image b, int Angle, the Button b1)
{
Angle Angle of=% 360;//radian conversion
Double radian Angle of=* Math. PI/180.0;
Double cosine=Math. Cos (radian);
A double sin=Math. Sin (radian);
Int BTW=b1. Width;
Int BTH=b1. Height;
//the original width and height of the
=b.W int w idth;
Int h=b.H eight;
Int W=(int) (Math. Max (Math. Abs (cos - h * W * sin), Math. Abs (cos + h W * * sin)));
Int H=(int) (Math. Max (Math. Abs (sin - H * w * cos), Math. Abs (sin cos + H * w *)));
//target bitmap
Image dsImage=new Bitmap (W, H);
System. Drawing. Graphics g=System. Drawing, Graphics. FromImage (dsImage);
G.I nterpolationMode=System. Drawing. Drawing2D. InterpolationMode. Bilinear;
G.S moothingMode=System. Drawing. Drawing2D. SmoothingMode. HighQuality;
//calculate offset
Point Offset=new Point ((W - W)/2, (H - H)/2);
//structure image display area: let the center of the image consistent with the center of the window
A Rectangle the rect=new Rectangle (Offset. X, Offset.. Y, w, h);
Point center=new Point (the rect. X + the rect. Width/2, the rect. Y + the rect. Height/2);
G.T ranslateTransform (center. X, center. Y);
G.R otateTransform (360 - Angle);
//restore image in the horizontal and vertical direction translation
G.T ranslateTransform - center. X - center. (Y);

G.D rawImage (b, the rect);
//back to the drawing of all transformation
G.R esetTransform ();
G.S ave ();
G.D ispose ();
//dsImage. Save (" yuancd. JPG ", System. Drawing. Imaging. ImageFormat. Jpeg);
Return dsImage;
}

Private void timer1_Tick (object sender, EventArgs e)
{
This. For the BackgroundImage=RotateImg2 (this) for the BackgroundImage, 90, enclosing for);
}
}
}

CodePudding user response:

Bevel edge than square edge, rotate the original place must not put ah, do you demand, can't change that either cut shows, or narrow, shows where can change is big

CodePudding user response:

http://bbs.cskin.net/thread-15494-1-1.html
Winform figure
  •  Tags:  
  • C #
  • Related