HBITMAP FrameBitmap(HBITMAP hBmp, COLORREF clrInColor, COLORREF clrOutColor, UINT inLineWidth, UINT outLineWidth) { CxImage ximage; ximage.CreateFromHBITMAP(hBmp); ximage.IncreaseBpp(24); UINT totalWidth = inLineWidth + outLineWidth; if (totalWidth == 0) return ximage.MakeBitmap(); LONG newWidth = ximage.GetWidth() + totalWidth * 2; LONG newHeight = ximage.GetHeight() + totalWidth * 2; RGBQUAD expandClr; expandClr.rgbBlue = GetBValue(clrInColor); expandClr.rgbGreen = GetGValue(clrInColor); expandClr.rgbRed = GetRValue(clrInColor); expandClr.rgbReserved = 0; ximage.Expand(newWidth, newHeight, expandClr); ximage.DrawLine(1, (newWidth - 1), 1, 1, clrOutColor); ximage.DrawLine(1, 1, 1, (newHeight - 1), clrOutColor); ximage.DrawLine((newWidth - 1), (newWidth - 1), 1, (newHeight - 1), clrOutColor); ximage.DrawLine((newWidth - 1), 1, (newHeight - 1), (newHeight - 1), clrOutColor); return ximage.MakeBitmap(); }
void DlgMix::SetMix() { pDocSrc = (CDemoDoc*) m_cbSrc.GetItemData(m_cbSrc.GetCurSel()); pDocDst = (CDemoDoc*) m_cbDst.GetItemData(m_cbDst.GetCurSel()); OpType = m_cbOpType.GetItemData(m_cbOpType.GetCurSel()); if (pDocSrc==0 || pDocDst==0) return; CxImage* pImageSrc = pDocSrc->GetImage(); CxImage* pImageDst = pDocDst->GetImage(); SetThumbs(pImageSrc,pImageDst); CxImage tmp; tmp.Copy(m_imageDst); tmp.Mix(m_imageSrc,(CxImage::ImageOpType)OpType,(long)(m_xoffset*m_ratio),(long)(m_yoffset*m_ratio),m_mixalpha!=0); if (m_mixalpha!=0){ RGBQUAD c={255,255,255,0}; tmp.SetTransColor(c); tmp.AlphaStrip(); } if (m_bitmap) DeleteObject(m_bitmap); m_bitmap = tmp.MakeBitmap(m_picture.GetDC()->m_hDC); m_picture.SetBitmap(m_bitmap); }
void DlgDataExt::UpdatePreview() { if (m_image){ CxImage tmp; tmp.Copy(*m_image,true,false,false); if (m_chk_preview.GetCheck()){ UpdateData(1); if (m_btn_graylevel.GetCheck()){ tmp.Threshold(m_thresh); } else { tmp.SelectionAddColor(tmp.RGBtoRGBQUAD(m_color)); tmp.SelectionSplit(&tmp); tmp.Negative(); } } tmp.IncreaseBpp(24); tmp.Resample(150,90,0); if (m_bitmap) DeleteObject(m_bitmap); m_bitmap = tmp.MakeBitmap(m_picture.GetDC()->m_hDC); m_picture.SetBitmap(m_bitmap); } }
HBITMAP CSkin::LoadImage(const char *filename) { CxImage image; image.Load(filename); if(!image.IsValid()) { return NULL; } return image.MakeBitmap(NULL); }
HBITMAP MixBitmap(HBITMAP hDstMix, HBITMAP hSrcMix, LONG xOffset, LONG yOffset) { CxImage ximage; ximage.CreateFromHBITMAP(hDstMix); ximage.IncreaseBpp(24); CxImage ximageStatus; ximageStatus.CreateFromHBITMAP(hSrcMix); ximage.MixFrom(ximageStatus, xOffset, yOffset); return ximage.MakeBitmap(); }
std::string UserListModule_Impl::getGrayLocalPathFromFilename(std::string& finename) { CString csFileName = util::stringToCString(finename); CString csGrayAvatarPath = module::getMiscModule()->getDownloadDir() + PREFIX_GRAY_AVATAR + csFileName; //本地磁盘存在 if (util::isFileExist(csGrayAvatarPath)) { return util::cStringToString(csGrayAvatarPath); } else { //不存在则对图片做灰度处理并且保存到本地 CxImage cximage; CString csAvatarPath = module::getMiscModule()->getDownloadDir() + csFileName; bool bSucc = cximage.Load(csAvatarPath); if (bSucc) { cximage.GrayScale(); module::getCaptureModule()->saveToFile(cximage.MakeBitmap(), csAvatarPath); } } return ""; }
DWORD CmdDrawZoom::CmdDrawAjustZooming::SetPoint(DWORD MouseAction, CPoint pt) { CmdDrawZoom *p = dynamic_cast<CmdDrawZoom*>(m_pOwner); if (enCmdMouseNone == MouseAction) { LP_MATERIALINFO pTempInfo = p->m_pReceiver->getComicStripData()->getSelectedInfo(); if (NULL == pTempInfo) { return FALSE; } CSize size = CSize(pt.x - pTempInfo->GetLTPoint().x, pt.y - pTempInfo->GetLTPoint().y); size.cx = max(size.cx, 24); size.cy = max(size.cy, 24); pTempInfo->SetFinalSize(size); if (pTempInfo->isPenDraw) { int width = pTempInfo->m_image.GetWidth(); int height = pTempInfo->m_image.GetHeight(); if (width<size.cx || height<size.cy) { int newWidth = max(width, size.cx); int newHeight = max(height, size.cy); CxImage tempImage = pTempInfo->m_image; pTempInfo->m_image.Create(newWidth, newHeight, 24, CXIMAGE_FORMAT_PNG); RGBQUAD rgb = pTempInfo->m_image.GetPixelColor(1,1); pTempInfo->m_image.SetTransIndex(0); pTempInfo->m_image.SetTransColor(rgb); HDC memdcOrg = CreateCompatibleDC(NULL); HBITMAP hbitmapOrg = tempImage.MakeBitmap(); HGDIOBJ pOldGDIOBJOrg = SelectObject(memdcOrg, hbitmapOrg); HDC memdc = CreateCompatibleDC(NULL); HBITMAP hbitmap = pTempInfo->m_image.MakeBitmap(); HGDIOBJ pOldGDIOBJ = SelectObject(memdc, hbitmap); BitBlt(memdc, 0, 0, width, height, memdcOrg, 0, 0, SRCCOPY); pTempInfo->m_image.CreateFromHBITMAP(hbitmap); SelectObject(memdc, pOldGDIOBJ); DeleteObject(hbitmap); DeleteDC(memdc); SelectObject(memdcOrg, pOldGDIOBJOrg); DeleteObject(hbitmapOrg); DeleteDC(memdcOrg); } } p->m_pReceiver->UpdateComicStrip(pTempInfo->nIDOwner); } else if (enCmdMouseLUp == MouseAction) { LP_MATERIALINFO pTempInfo = p->m_pReceiver->getComicStripData()->getSelectedInfo(); if (NULL == pTempInfo) { return FALSE; } CSize size = CSize(pt.x - pTempInfo->GetLTPoint().x, pt.y - pTempInfo->GetLTPoint().y); size.cx = max(size.cx, 24); size.cy = max(size.cy, 24); pTempInfo->SetFinalSize(size); if (pTempInfo->isPenDraw) { int width = pTempInfo->m_image.GetWidth(); int height = pTempInfo->m_image.GetHeight(); if (width<size.cx || height<size.cy) { CxImage tempImage = pTempInfo->m_image; pTempInfo->m_image.Create(size.cx, size.cy, 24, CXIMAGE_FORMAT_PNG); RGBQUAD rgb = pTempInfo->m_image.GetPixelColor(1,1); pTempInfo->m_image.SetTransIndex(0); pTempInfo->m_image.SetTransColor(rgb); HDC memdcOrg = CreateCompatibleDC(NULL); HBITMAP hbitmapOrg = tempImage.MakeBitmap(); HGDIOBJ pOldGDIOBJOrg = SelectObject(memdcOrg, hbitmapOrg); HDC memdc = CreateCompatibleDC(NULL); HBITMAP hbitmap = pTempInfo->m_image.MakeBitmap(); HGDIOBJ pOldGDIOBJ = SelectObject(memdc, hbitmap); BitBlt(memdc, 0, 0, width, height, memdcOrg, 0, 0, SRCCOPY); pTempInfo->m_image.CreateFromHBITMAP(hbitmap); SelectObject(memdc, pOldGDIOBJ); DeleteObject(hbitmap); DeleteDC(memdc); SelectObject(memdcOrg, pOldGDIOBJOrg); DeleteObject(hbitmapOrg); DeleteDC(memdcOrg); } } p->m_pReceiver->SaveFile(); p->m_pReceiver->UpdateComicStrip(pTempInfo->nIDOwner); p->m_pDsState = &p->m_dsZoomBgn; p->m_pReceiver->SetCursor(); p->m_nDrawState = enDrawIdle; } return TRUE; }