如何旋转位图图像? [英] How to rotate a bitmap image ?

查看:89
本文介绍了如何旋转位图图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用MFC在C ++中旋转位图图像?
我不想使用GDI.是否可以只更改此代码中的x和y值?

How to rotate a bitmap image in C++ using MFC?
I dont want to use GDI. Is it possible by only changing x and y values in this code?

CBitmap img;
CDC dc;
BITMAP bmp;
img.LoadBitmapW(IDB_BITMAP1);
img.GetBitmap(&bmp);
CDC* pDC = this->GetDC();
dc.CreateCompatibleDC(pDC);
CBitmap* pOld = dc.SelectObject(&img);
for(int y = 0; y < bmp.bmHeight; y++)
{
    for(int x = 0; x < bmp.bmWidth; x++)
    {
        COLORREF rgb = dc.GetPixel(x, y);
        BYTE r = GetRValue(rgb);
        BYTE g = GetGValue(rgb);
        BYTE b = GetBValue(rgb);
        dc.SetPixel(x, y, RGB(r,g,b));
    }
}
pDC->BitBlt(200, 200, bmp.bmWidth, bmp.bmHeight, &dc, 0, 0, SRCCOPY);
dc.SelectObject(pOld);



请有人尽快答复,因为这是进行项目的最后一天,明天是提交的项目.



Please someone reply soon, as this is the last day to work on project, tomorrow is its submission.

推荐答案

为什么您不只是尝试??

对我来说,您似乎感到很困惑……您应该使项目提交失败.

1)如果不将COLORRF组合在一起而不进行任何操作,又为什么将其拆分为多个组件?

2)如果您将像素写到新位置,则旧像素将被替换.但是您以后仍然需要阅读该像素...

3)旋转意味着宽"变为长".如果(x,y)的x≥x,则将(y,x)存储在哪里?高度或y>宽度?

最好创建一个与源图像不同且具有适当大小的目标图像.
Why don''t you just try ??

To me you seems soooo confused ... that you deserve to fail your project submission.

1) Why do you split the COLORRF into its component if you than re-put them together without doing any operation on them?

2) If you write a pixel the new position, the old pixel will be replaced. But you still need to read that pixel later...

3) A rotation implies that what is "wide" becomes "long". Where do you store (y,x) if (x,y) has x > height or y > width ?

Better to create a destination image different than the source, with appropriate sizes.


这篇关于如何旋转位图图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆