不要usingsystem.windows.media
在提升你需要該引用的地方System.Drawing.Image
或者將滑鼠移動到提示有問題的地方捕獲一下那個小方格,然後選擇System.Drawing.Image這樣就行了
privatevoidbutton1_Click(objectsender,EventArgse)
{
Bitmapbox2=newBitmap(pictureBox1.Image);
floatx=(float)Double.Parse(textBox1.Text);
box2=RotateBitmap(box2,x,this.pictureBox2.BackColor);
System.Drawing.Imageimage=System.Drawing.Image.FromHbitmap(box2.GetHbitmap());
pictureBox2.Image=image;
}
publicBitmapRotateBitmap(Bitmapbmp,floatangle,ColorbkColor)
intw=bmp.Width+2;
inth=bmp.Height+2;
PixelFormatpf;
if(bkColor==Color.Transparent)
pf=PixelFormat.Format32bppArgb;
else
pf=bmp.PixelFormat;
Bitmaptmp=newBitmap(w,h,pf);
Graphicsg=Graphics.FromImage(tmp);
g.Clear(bkColor);
g.DrawImageUnscaled(bmp,1,1);
g.Dispose();
GraphicsPathpath=newGraphicsPath();
path.AddRectangle(newRectangleF(0f,0f,w,h));
Matrixmtrx=newMatrix();
mtrx.Rotate(angle);
RectangleFrct=path.GetBounds(mtrx);
Bitmapdst=newBitmap((int)rct.Width,(int)rct.Height,pf);
g=Graphics.FromImage(dst);
g.TranslateTransform(-rct.X,-rct.Y);
g.RotateTransform(angle);
g.InterpolationMode=InterpolationMode.HighQualityBicubic;
g.DrawImageUnscaled(tmp,0,0);
tmp.Dispose();
returndst;
不要usingsystem.windows.media
在提升你需要該引用的地方System.Drawing.Image
或者將滑鼠移動到提示有問題的地方捕獲一下那個小方格,然後選擇System.Drawing.Image這樣就行了
privatevoidbutton1_Click(objectsender,EventArgse)
{
Bitmapbox2=newBitmap(pictureBox1.Image);
floatx=(float)Double.Parse(textBox1.Text);
box2=RotateBitmap(box2,x,this.pictureBox2.BackColor);
System.Drawing.Imageimage=System.Drawing.Image.FromHbitmap(box2.GetHbitmap());
pictureBox2.Image=image;
}
publicBitmapRotateBitmap(Bitmapbmp,floatangle,ColorbkColor)
{
intw=bmp.Width+2;
inth=bmp.Height+2;
PixelFormatpf;
if(bkColor==Color.Transparent)
{
pf=PixelFormat.Format32bppArgb;
}
else
{
pf=bmp.PixelFormat;
}
Bitmaptmp=newBitmap(w,h,pf);
Graphicsg=Graphics.FromImage(tmp);
g.Clear(bkColor);
g.DrawImageUnscaled(bmp,1,1);
g.Dispose();
GraphicsPathpath=newGraphicsPath();
path.AddRectangle(newRectangleF(0f,0f,w,h));
Matrixmtrx=newMatrix();
mtrx.Rotate(angle);
RectangleFrct=path.GetBounds(mtrx);
Bitmapdst=newBitmap((int)rct.Width,(int)rct.Height,pf);
g=Graphics.FromImage(dst);
g.Clear(bkColor);
g.TranslateTransform(-rct.X,-rct.Y);
g.RotateTransform(angle);
g.InterpolationMode=InterpolationMode.HighQualityBicubic;
g.DrawImageUnscaled(tmp,0,0);
g.Dispose();
tmp.Dispose();
returndst;
}