我的代码如下 CoCreateInstance(CLSID_ImagingFactory,NULL,CLSCTX_INPROC_SERVER,IID_IImagingFactory,
(void **)&pImgFactory); //创建COM组件
pImgFactory->CreateImageFromFile(L"\\Storage Card\\imgBrowsedown1.png",&pImage);//读取图片信息
// memHDC = CreateCompatibleDC(hdc);//关联两个DC
// int width= rect[0].right -rect[0].left,heigth = rect[0].top-rect[0].bottom;
HBITMAP hBitmap = CreateCompatibleBitmap(hdc, m_rect[0].Width(),m_rect[0].Height());//在缓冲中建立BITMAP
SelectObject(memHDC, hBitmap);
BitBlt(memHDC, 0, 0, m_rect[0].Width(),m_rect[0].Height(), hdc, m_rect[0].TopLeft().x, m_rect[0].TopLeft().y, SRCCOPY);//背景提前载入
pImage-> Draw(memHDC, CRect(0,0,87,90),NULL);//
BitBlt( hdc,m_rect[0].TopLeft().x, m_rect[0].TopLeft().y, m_rect[0].Width(),
m_rect[0].Height(),memHDC, 0, 0, SRCCOPY);
结果显示出来的png图片的边框越来越粗,据说叫什么ALPHABLEND区域,我该如何解决??我的代码有什么错误么?我的系统是WINCE 5.0,EVC开发。谢谢
你没有用到ALPHA混合的地方啊,怎么会越来越模糊呢,先用背景色把WINDOWS清一遍呢?如果这样现象就没了的话,看一下你COM的问题吧。
CPoint pt;
GetCursorPos(&pt);
CWnd* tWnd = WindowFromPoint(pt);
HWND hWnd = tWnd->GetSafeHwnd(); //窗口句柄
HDC hdc = ::GetDC(hWnd);
HDC memHDC = CreateCompatibleDC(hdc);
IImagingFactory *pImgFactory = NULL;
IImage *pImage = NULL;
CoInitializeEx(NULL,COINIT_MULTITHREADED);//初始化
if (m_NavRefresh || m_currentPick == 0)//图片
{
CoCreateInstance(CLSID_ImagingFactory,NULL,CLSCTX_INPROC_SERVER,IID_IImagingFactory,
(void **)&pImgFactory); //创建COM组件
pImgFactory->CreateImageFromFile(L"\\Storage Card\\imgBrowsedown1.png",&pImage);//读取图片信息
// memHDC = CreateCompatibleDC(hdc);//关联两个DC
// int width= rect[0].right -rect[0].left,heigth = rect[0].top-rect[0].bottom;
HBITMAP hBitmap = CreateCompatibleBitmap(hdc, m_rect[0].Width(),m_rect[0].Height());//在缓冲中建立BITMAP
SelectObject(memHDC, hBitmap);
BitBlt(memHDC, 0, 0, m_rect[0].Width(),m_rect[0].Height(), hdc, m_rect[0].TopLeft().x, m_rect[0].TopLeft().y, SRCCOPY);//背景提前载入
pImage-> Draw(memHDC, CRect(0,0,87,90),NULL);//
BitBlt( hdc,m_rect[0].TopLeft().x, m_rect[0].TopLeft().y, m_rect[0].Width(),
m_rect[0].Height(),memHDC, 0, 0, SRCCOPY);
// ShowPic(hdc, _T("\\Storage Card\\imgBrowseup1.png"),m_rect[0]);
}