zoukankan      html  css  js  c++  java
  • GDI+ 旋转图片(jpg,bmg,GDI+支持的图像格式)

    为了做旋转图片,用了我太多的精力,位图旋转的实现实在是太麻烦了,直到前几天我看到了GDI+,才想出来了这个简单的旋转图像的方法,今天太累了,改天补充出来动画的旋转,希望各位同学一起分享!

    在对话框做中的OnPaint()方法中直接写入复制代码就可以了,其他的旋转角度可以自己补充

    void CgdiTestDlg::OnPaint()
    {
     CPaintDC dc(this); // 用于绘制的设备上下文
     if (IsIconic())
     {

      SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

      // 使图标在工作矩形中居中
      int cxIcon = GetSystemMetrics(SM_CXICON);
      int cyIcon = GetSystemMetrics(SM_CYICON);
      CRect rect;
      GetClientRect(&rect);
     // MessageBox(rect.Width());
      
      int x = (rect.Width() - cxIcon + 1) / 2;
      int y = (rect.Height() - cyIcon + 1) / 2;

      // 绘制图标
      dc.DrawIcon(x, y, m_hIcon);
     }
     else
     {
      CDialog::OnPaint();
     }
     Graphics graphics(dc.m_hDC);
     CBrush cbrush(RGB(0,0,255));
     
     Image image(_T("E:\\dyr\\dyr\\DSCF2741.JPG"));
     
     //正常的显示
         Point destPoints1[3] ={Point(10,10),Point(10,410),Point(310,10)};
     //旋转90度显示
     // Point destPoints1[3] ={Point(10,410),Point(10,10),Point(310,410)};


     
     graphics.DrawImage(&image,destPoints1,3);

    //graph.DrawImage(&image,100,100);

    //graph.RotateTransform(30.0f);

    //graph.DrawImage(&image,200,200);

    }

  • 相关阅读:
    第一次热身赛和正式比赛感想
    简明解释算法中的大O符号
    poj 3045
    poj 3104
    poj 3273
    poj 3258
    poj 2456
    二分法小结
    Poj 2718 Smallest Difference
    GCJ——Crazy Rows (2009 Round 2 A)
  • 原文地址:https://www.cnblogs.com/zhixing/p/1990666.html
Copyright © 2011-2022 走看看