gdi加载灰度图像先转成彩色,去除噪点
This commit is contained in:
parent
570cc3f686
commit
82b717b16a
|
@ -1,4 +1,4 @@
|
||||||
#include "HGImage.h"
|
#include "HGImage.h"
|
||||||
#include "HGInc.h"
|
#include "HGInc.h"
|
||||||
#if defined(HG_CMP_MSC)
|
#if defined(HG_CMP_MSC)
|
||||||
#include <combaseapi.h>
|
#include <combaseapi.h>
|
||||||
|
@ -525,12 +525,11 @@ static HGResult LoadGdiImage(Gdiplus::Image* pImage, const HGImageRoi* roi, HGUI
|
||||||
|
|
||||||
HBITMAP hBmp = NULL;
|
HBITMAP hBmp = NULL;
|
||||||
HGBase_GetHBITMAPOfImage(*image, &hBmp);
|
HGBase_GetHBITMAPOfImage(*image, &hBmp);
|
||||||
if (NULL != hBmp)
|
if (NULL != hBmp && (HGBASE_IMGTYPE_BGR == type || HGBASE_IMGTYPE_BGRA == type))
|
||||||
{
|
{
|
||||||
HDC hMem = CreateCompatibleDC(NULL);
|
HDC hMem = CreateCompatibleDC(NULL);
|
||||||
HBITMAP hOldBmp = (HBITMAP)SelectObject(hMem, hBmp);
|
HBITMAP hOldBmp = (HBITMAP)SelectObject(hMem, hBmp);
|
||||||
Gdiplus::Graphics graphics(hMem);
|
Gdiplus::Graphics graphics(hMem);
|
||||||
graphics.SetInterpolationMode(Gdiplus::InterpolationModeHighQuality);
|
|
||||||
graphics.DrawImage(pImage, (INT)roi2.left, (INT)roi2.top,
|
graphics.DrawImage(pImage, (INT)roi2.left, (INT)roi2.top,
|
||||||
(INT)(roi2.right - roi2.left), (INT)(roi2.bottom - roi2.top));
|
(INT)(roi2.right - roi2.left), (INT)(roi2.bottom - roi2.top));
|
||||||
SelectObject(hMem, hOldBmp);
|
SelectObject(hMem, hOldBmp);
|
||||||
|
@ -544,6 +543,10 @@ static HGResult LoadGdiImage(Gdiplus::Image* pImage, const HGImageRoi* roi, HGUI
|
||||||
type2 = HGBASE_IMGTYPE_BGR;
|
type2 = HGBASE_IMGTYPE_BGR;
|
||||||
else if (HGBASE_IMGTYPE_RGBA == type)
|
else if (HGBASE_IMGTYPE_RGBA == type)
|
||||||
type2 = HGBASE_IMGTYPE_BGRA;
|
type2 = HGBASE_IMGTYPE_BGRA;
|
||||||
|
else if (HGBASE_IMGTYPE_GRAY == type)
|
||||||
|
type2 = HGBASE_IMGTYPE_BGR;
|
||||||
|
else if (HGBASE_IMGTYPE_BINARY == type)
|
||||||
|
type2 = HGBASE_IMGTYPE_BGR;
|
||||||
|
|
||||||
HGImage image2 = NULL;
|
HGImage image2 = NULL;
|
||||||
ret = LoadGdiImage(pImage, roi, type2, origin, &image2);
|
ret = LoadGdiImage(pImage, roi, type2, origin, &image2);
|
||||||
|
|
Loading…
Reference in New Issue