|
直接用IImage 旋转 可以实现任意旋转,只是速度不快。
给你贴代码
BOOL CImageMaster::RotateImage(int iAngle, HDC hdc, ImageDrawMode mode, const RECT *pDstRect, const RECT *pSrcRect, BOOL bDraw)
{
if(pDstRect == NULL)
{
return FALSE;
}
if (m_ImageInfo.Width >= 1024 || m_ImageInfo.Height >= 768)
{
RECT rcDraw = {0};
CalculateDrawArea(mode,pDstRect,pSrcRect,&rcDraw);
m_ImageInfo.Width = rcDraw.right - rcDraw.left;
m_ImageInfo.Height = rcDraw.bottom - rcDraw.top;
}
m_pImagingFactory->CreateBitmapFromImage(m_pImage, m_ImageInfo.Width, m_ImageInfo.Height, m_ImageInfo.PixelFormat, InterpolationHintDefault, &m_pBitmap);
if(m_pImage != NULL)
{
m_pImage->Release();
m_pImage = NULL;
}
m_pBitmap->QueryInterface(IID_IBasicBitmapOps, (void **)&m_pBasicBitmap);
if (m_pBitmap != NULL)
{
m_pBitmap->Release();
m_pBitmap = NULL;
}
m_pBasicBitmap->Rotate((float)iAngle, InterpolationHintDefault, (IBitmapImage **)&m_pBitmap);
if (m_pBasicBitmap != NULL)
{
m_pBasicBitmap->Release();
m_pBasicBitmap = NULL;
}
m_pBitmap->QueryInterface(IID_IImage, (void **)&m_pImage);
if (m_pBitmap != NULL)
{
m_pBitmap->Release();
m_pBitmap = NULL;
}
m_pImage->GetImageInfo(&m_ImageInfo);
if(IsOKMemoryDC(&m_IntegrityMemDCInfo) == FALSE)
{
if(IsOKImagingInterfaces() == FALSE)
{
return FALSE;
}
if(CreateMemoryDC(hdc,&m_IntegrityMemDCInfo,m_ImageInfo.Width,m_ImageInfo.Height) == FALSE)
{
return FALSE;
}
RECT rcMemDC = {0,0,m_ImageInfo.Width,m_ImageInfo.Height};
HRESULT hr = m_pImage->Draw(m_IntegrityMemDCInfo.hdc,&rcMemDC,NULL);
if(FAILED(hr))
{
ReleaseImagingInterfaces();
DeleteMemoryDC(&m_IntegrityMemDCInfo);
return FALSE;
}
}
BOOL bResult = TRUE;
if(bDraw == TRUE)
{
RECT rcDraw = {0};
CalculateDrawArea(mode,pDstRect,pSrcRect,&rcDraw);
bResult = Draw(hdc,&rcDraw,&m_IntegrityMemDCInfo,pSrcRect);
}
return bResult;
} |
|