使用GDIPlus调整大小的模糊顶边

时间:2010-01-08 09:40:22

标签: c++ windows gdi+ interpolation

我正在使用以下代码在C中使用GDI +调整位图大小。即使对于该区域应为白色的图像,我也会获得上边缘的灰度值。当插值是最近邻居时,问题消失。但是,我尝试使用ImageMagick进行双三次插值,看起来很好。我应该知道的任何限制问题?我的缩放方法是不是以某种方式错了?谢谢!

(输入:     destSize:destination Gdiplus :: Size     m_pBitmap:源位图)

Rect destRect(Point(0,0), destSize);
Bitmap *pBitmap24BPP =  new Bitmap(destSize.Width, destSize.Height, PixelFormat24bppRGB);
pBitmap24BPP->SetResolution(m_pBitmap->GetHorizontalResolution(), m_pBitmap->GetVerticalResolution());  
Graphics *pGraphics = Graphics::FromImage(pBitmap24BPP);
pGraphics->SetInterpolationMode(InterpolationModeHighQualityBilinear);
pGraphics->DrawImage(m_pBitmap, destRect, 0, 0, m_pBitmap->GetWidth(), m_pBitmap->GetHeight()   , UnitPixel, NULL);

//cleanup

1 个答案:

答案 0 :(得分:1)

我一直在看类似的事情。我没有时间研究它,但我有一种感觉,因为GDI +图像缩放器错误地使用“偏离顶部边缘”的像素值,这将全部为零 - 使其变黑。

正确调整图像大小应识别您已到达图像的边缘,并进行适当处理。

相关问题