【WIN32开发,GDI+旋转图片】

int angle = 0;//角度

graphics.RotateTransform(angle, MatrixOrderAppend);
graphics.TranslateTransform(0, 0, MatrixOrderAppend);//
graphics.DrawImage(&image, 0, 0, width, height);//
graphics.ResetTransform();

不是很好用的方法:

width = image.GetWidth();
    height = image.GetHeight();
    //绘图
    Graphics graphics(hdcBuffer);
    graphics.DrawImage(&image, 0, 0, width, height);//原图

//旋转90度

nX = width + 5;
    nY = 0;
    Point points90[] = {
        Point(nX + height, nY),
        Point(nX + height, nY + width),
        Point(nX, nY) };

    graphics.DrawImage(&image, points90, 3);//
    

    // 旋转180度图像的输出位置
    nX = width + height + 10;
    nY = 0;

    Point points180[] = {
        Point(nX + width, nY + height),
        Point(nX, nY + height),
        Point(nX + width, nY) };

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

// 初始化GDI+  
    Gdiplus::GdiplusStartupInput gdiplusStartupInput;
    ULONG_PTR gdiplusToken;
    Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
    Image image(TEXT(".\\img\\61.png"));
    int width = image.GetWidth();
    int height = image.GetHeight();
    Graphics graphics(hdcBuffer);
    graphics.RotateTransform(angle, MatrixOrderAppend);//旋转角度-150-150
    graphics.TranslateTransform(x+21.5, y+21.5, MatrixOrderAppend);//旋转坐标(x,旋转的横坐标+相对坐标)(y纵坐标+相对坐标)
    graphics.DrawImage(&image, 4, 0, -width, -height);//旋转区域(旋转点坐标(0,0)为右下角,需要改为图标中心点旋转)
    graphics.ResetTransform();
    Gdiplus::GdiplusShutdown(gdiplusToken);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值