如何在VC中制作旋转图片效果

来源:百度知道 编辑:UC知道 时间:2024/05/26 10:53:56
我要制作一个音量旋钮,现在的思路是:利用我所截取的图片,然后根据鼠标的事件响应,然后来实现位图的旋转。但是我没有学过数字图像,望哪位大侠指教一下该怎么做,最好提供源码进行参考。

// RotateDIB - Create a new bitmap with rotated image
// Returns - Returns new bitmap with rotated image
// hDIB - Device-independent bitmap to rotate
// fDegrees - Angle of rotation in degree
// clrBack - Color of pixels in the resulting bitmap that do
// not get covered by source pixels
HDIB RotateDIB(HDIB hDIB, double fDegrees, COLORREF clrBack)
{
WaitCursorBegin();

// Get source bitmap info
LPBITMAPINFO lpBmInfo = (LPBITMAPINFO)GlobalLock(hDIB);
int bpp = lpBmInfo->bmiHeader.biBitCount; // Bits per pixel

int nColors = lpBmInfo->bmiHeader.biClrUsed ? lpBmInfo->bmiHeader.biClrUsed :
1 << bpp;
int nWidth = lpBmInfo->bmiHeader.biWidth;
int nHeight = lpBmInfo->bmiHeader.biHeight;
int nRowBytes = ((((nWidth * bpp) + 31) & ~31) / 8);

// Make sure height is positive and biCompression is BI_RGB or BI_BITFIELDS
DWORD compression = lpBm