回覆列表
  • 1 # 誰暖冬季影紫花開

    不要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;

    }

  • 中秋節和大豐收的關聯?
  • 八個月大的孩子老是往地上扔東西怎麼辦?