本文整理汇总了C++中CImage::Detach方法的典型用法代码示例。如果您正苦于以下问题:C++ CImage::Detach方法的具体用法?C++ CImage::Detach怎么用?C++ CImage::Detach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CImage
的用法示例。
在下文中一共展示了CImage::Detach方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendImageToClipboard
bool CozyCaptureWindow::SendImageToClipboard(CImage &Img)
{
if (OpenClipboard())
{
HBITMAP hbitmap_dib = Img.Detach();
if (!hbitmap_dib)
{
return false;
}
DIBSECTION ds;
::GetObject(hbitmap_dib, sizeof(DIBSECTION), &ds);
ds.dsBmih.biCompression = BI_RGB;
HDC hdc = ::GetDC(NULL);
HBITMAP hbitmap_ddb = ::CreateDIBitmap(hdc, &ds.dsBmih, CBM_INIT, ds.dsBm.bmBits, (BITMAPINFO*)&ds.dsBmih, DIB_RGB_COLORS);
::ReleaseDC(NULL, hdc);
::EmptyClipboard();
::SetClipboardData(CF_BITMAP, hbitmap_ddb);
::CloseClipboard();
return true;
}
return false;
}
示例2: LoadRichEditImage
//处理图片
bool CRichEditMessage::LoadRichEditImage(HINSTANCE hInstance, UINT uResourceID, CDataObject&ImageDataObject)
{
//加载图片
CBitImage ImageFile;
ImageFile.LoadFromResource(hInstance,uResourceID);
//失败判断
if (ImageFile.IsNull()==true)
{
ASSERT(FALSE);
return false;
}
//创建表情
CImage ImageRichEdit;
ImageRichEdit.Create(ImageFile.GetWidth(),ImageFile.GetHeight(),32);
//绘画表情
CDC * pDC=CDC::FromHandle(ImageRichEdit.GetDC());
pDC->FillSolidRect(0,0,ImageFile.GetWidth(),ImageFile.GetHeight(),m_crFillColor);
ImageFile.TransDrawImage(pDC,0,0,RGB(255,0,255));
//设置图片
ImageRichEdit.ReleaseDC();
ImageDataObject.SetImage(ImageRichEdit.Detach());
return true;
}
示例3: LoadImage
void CbehaviorView::LoadImage()
{
HBITMAP hBitmap;
CString filename;
CString BMPFolder;
CString str;
CImage layerPng;
//str.Format("layer (%d).png", layernum);
//filename = BMPFolder + "\\" + str;
filename = "D:\\fish_editor\\mini_hammer-master\\workplace\\media\\fish_base\\plist\\8goldItem.png";
layerPng.Load(filename);
hBitmap=layerPng.Detach();
CBitmap bmp;
BITMAP l_bitMap;
bmp.Attach(hBitmap);
bmp.GetBitmap(&l_bitMap);
int height = l_bitMap.bmHeight;
int width = l_bitMap.bmWidth;
bmp.GetBitmapBits(128 * 128 * 4, m_lpBuf);
}
示例4: OnEraseBkgnd
BOOL CChildView::OnEraseBkgnd(CDC* pDC)
{
CRect r;
CAutoLock cAutoLock(&m_csLogo);
CImage img;
img.Attach(m_logo);
if (((CMainFrame*)GetParentFrame())->IsSomethingLoaded()) {
pDC->ExcludeClipRect(m_vrect);
} else if (!img.IsNull()) {
GetClientRect(r);
int w = min(img.GetWidth(), r.Width());
int h = min(img.GetHeight(), r.Height());
int x = (r.Width() - w) / 2;
int y = (r.Height() - h) / 2;
r = CRect(CPoint(x, y), CSize(w, h));
int oldmode = pDC->SetStretchBltMode(STRETCH_HALFTONE);
img.StretchBlt(*pDC, r, CRect(0, 0, img.GetWidth(), img.GetHeight()));
pDC->SetStretchBltMode(oldmode);
pDC->ExcludeClipRect(r);
}
img.Detach();
GetClientRect(r);
pDC->FillSolidRect(r, 0);
return TRUE;
}
示例5:
void TabOne::OnBnClickedButton2()
{
countImage -=1;
cvSaveImage(savePath,img0[countImage]);
CImage img;
img.Load(savePath);
m_PicCtrl.SetBitmap((HBITMAP)img.Detach());
if(countImage<4)
SetDlgItemTextA(IDC_EDIT1, "Please Click LEFT EYE critical points");
if(countImage>=4&& countImage<8)
SetDlgItemTextA(IDC_EDIT1, "Please Click RIGHT EYE critical points");
//MessageBox("Please Click RIGHT EYE critical points!!!!!!", "Click Critical Points Selection", MB_OK | MB_ICONEXCLAMATION);
if(countImage<11 && countImage >=8)
SetDlgItemTextA(IDC_EDIT1, "Please Click NOSE critical points");
//MessageBox("Please Click NOSE critical points!!!!!!", "Click Critical Points Selection", MB_OK | MB_ICONEXCLAMATION);
if(countImage>=11)
SetDlgItemTextA(IDC_EDIT1, "Please Click MOUTH critical points");
//MessageBox("Please Click MOUTH critical points!!!!!!", "Click Critical Points Selection", MB_OK | MB_ICONEXCLAMATION);
//cvShowImage(name, img0[countImage-1]);
}
示例6: InitExpressItem
//输入解释
void CExpressionItem::InitExpressItem(LPCTSTR pszChineseName, LPCTSTR pszTrancelate, UINT uIDResource)
{
//设置变量
m_uImageID=uIDResource;
lstrcpyn(m_szTrancelate,pszTrancelate,CountArray(m_szTrancelate));
lstrcpyn(m_szChineseName,pszChineseName,CountArray(m_szChineseName));
m_wTranceLength=lstrlen(m_szTrancelate);
//加载图片
CSkinImage ImageFile;
ImageFile.LoadFromResource(GetModuleHandle(CLIENT_SHARE_DLL_NAME),uIDResource);
//创建表情
CImage ImageExpression;
ASSERT(ImageFile.GetWidth()==EP_PIC_WHIDE);
ASSERT(ImageFile.GetHeight()==EP_PIC_HIGHT);
ImageExpression.Create(EP_PIC_WHIDE,EP_PIC_HIGHT,32);
//绘画表情
CDC * pDC=CDC::FromHandle(ImageExpression.GetDC());
pDC->FillSolidRect(0,0,EP_PIC_WHIDE,EP_PIC_HIGHT,COLOR_CHAR_BK);
ImageFile.AlphaDrawImage(pDC,0,0,RGB(255,0,255));
//设置图片
ImageExpression.ReleaseDC();
m_ImageDataObject.SetImage(ImageExpression.Detach());
return;
};
示例7: OnEraseBkgnd
BOOL CChildView::OnEraseBkgnd(CDC* pDC)
{
CRect r;
CImage img;
img.Attach(m_img);
if ((m_pMainFrame->GetLoadState() != MLS::CLOSED || (!m_bFirstMedia && m_pMainFrame->m_controls.DelayShowNotLoaded())) &&
!m_pMainFrame->IsD3DFullScreenMode() && !m_pMainFrame->m_fAudioOnly) {
pDC->ExcludeClipRect(m_vrect);
} else if (!img.IsNull()) {
const double dImageAR = double(img.GetWidth()) / img.GetHeight();
GetClientRect(r);
int width = r.Width();
int height = r.Height();
if (!m_bCustomImgLoaded) {
// Limit logo size
// TODO: Use vector logo to preserve quality and remove limit.
width = std::min(img.GetWidth(), width);
height = std::min(img.GetHeight(), height);
}
double dImgWidth = height * dImageAR;
double dImgHeight;
if (width < dImgWidth) {
dImgWidth = width;
dImgHeight = dImgWidth / dImageAR;
} else {
dImgHeight = height;
}
int x = std::lround((r.Width() - dImgWidth) / 2.0);
int y = std::lround((r.Height() - dImgHeight) / 2.0);
r = CRect(CPoint(x, y), CSize(std::lround(dImgWidth), std::lround(dImgHeight)));
if (!r.IsRectEmpty()) {
if (m_resizedImg.IsNull() || r.Width() != m_resizedImg.GetWidth() || r.Height() != m_resizedImg.GetHeight() || img.GetBPP() != m_resizedImg.GetBPP()) {
m_resizedImg.Destroy();
m_resizedImg.Create(r.Width(), r.Height(), std::max(img.GetBPP(), 24));
HDC hDC = m_resizedImg.GetDC();
SetStretchBltMode(hDC, STRETCH_HALFTONE);
img.StretchBlt(hDC, 0, 0, r.Width(), r.Height(), SRCCOPY);
m_resizedImg.ReleaseDC();
}
m_resizedImg.BitBlt(*pDC, r.TopLeft());
pDC->ExcludeClipRect(r);
}
}
img.Detach();
GetClientRect(r);
pDC->FillSolidRect(r, 0);
return TRUE;
}
示例8: LoadBmpFromImageFile
HBITMAP LoadBmpFromImageFile(LPCTSTR lpszFileName)
{
HBITMAP hBitmap = NULL;
//Gdiplus::Bitmap bmp(lpszFileName, false);
CImage image;
image.Load(lpszFileName);
hBitmap = image.Detach();
return hBitmap;
}
示例9: LoadImage
BOOL CEn_Bitmap::LoadImage(LPCTSTR szImagePath, COLORREF crBack)
{
ASSERT(m_hObject == NULL); // only attach once, detach on destroy
if (m_hObject != NULL)
return FALSE;
// If GDI+ is available, use that API because it supports more file formats and images with alpha channels.
// That DLL is installed with WinXP is available as redistributable from Microsoft for Win98+. As this DLL
// may not be available on some OS but we have to link statically to it, we have to take some special care.
//
// NOTE: Do *NOT* forget to specify /DELAYLOAD:gdiplus.dll as link parameter.
static int _bGdiPlusInstalled = -1;
if (_bGdiPlusInstalled == -1)
{
_bGdiPlusInstalled = 0;
HMODULE hLib = LoadLibrary(_T("gdiplus.dll"));
if (hLib != NULL)
{
_bGdiPlusInstalled = GetProcAddress(hLib, "GdiplusStartup") != NULL;
FreeLibrary(hLib);
}
}
if (_bGdiPlusInstalled > 0)
{
CImage img;
if (SUCCEEDED(img.Load(szImagePath)))
{
CBitmap::Attach(img.Detach());
return TRUE;
}
}
BOOL bResult = FALSE;
CFile cFile;
CFileException e;
if (cFile.Open(szImagePath, CFile::modeRead | CFile::typeBinary | CFile::shareDenyWrite, &e))
{
int nSize = (int)cFile.GetLength();
BYTE* pBuff = new BYTE[nSize];
if (cFile.Read(pBuff, nSize) > 0)
{
IPicture* pPicture = LoadFromBuffer(pBuff, nSize);
if (pPicture)
{
bResult = Attach(pPicture, crBack);
pPicture->Release();
}
}
delete [] pBuff;
}
return bResult;
}
示例10: SaveBitmapToFile
void Utils::SaveBitmapToFile(CBitmap * bmp)
{
CImage image;
CString Path;
Path.Format("C:\\test%d.bmp", counter);
image.Attach(*bmp);
image.Save(Path, Gdiplus::ImageFormatBMP);
image.Detach();
counter++;
}
示例11: SaveImage
HRESULT BMPanvas::SaveImage(CString name)
{
HRESULT ret = E_FAIL;
CImage TI;
if(HasImage())
{
TI.Attach(GetHBMP(BMP_DETACH));
ret=TI.Save(name,ImageFormatPNG);
Attach(TI.Detach());
}
return ret;
}
示例12: LoadFromFile
// Load bitmap from image file.
bool CMyStatic::LoadFromFile(LPCTSTR lpszFileName)
{
bool bRet = false;
if (lpszFileName && *lpszFileName)
{
CImage Image;
bRet = SUCCEEDED(Image.Load(lpszFileName));
if (bRet)
bRet = ReplaceBitmap(Image.Detach());
}
return bRet;
}
示例13: OnHPTimer
LRESULT CChildView::OnHPTimer(WPARAM wParam, LPARAM)
{
// Get the screen region to copy.
//
CRect rect(MeaToolMgr::Instance().GetRegion());
// Create a memory context and bitmap for it.
//
HDC screenDC = ::CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
HDC memDC = ::CreateCompatibleDC(screenDC);
HBITMAP screenBitmap = ::CreateCompatibleBitmap(screenDC, rect.Width(), rect.Height());
::SelectObject(memDC, screenBitmap);
// Copy the screen region to the bitmap.
//
::BitBlt(memDC, 0, 0, rect.Width(), rect.Height(),
screenDC, rect.left, rect.top, SRCCOPY);
if((MeaTimer *)wParam == &m_screenGrabTimer)
{
// Save bitmap to file
//
CImage img;
CTime currentTime = CTime::GetCurrentTime();
CString newFilename = currentTime.Format(_T("Grab %Y-%m-%d %H.%M.%S"));
CString filePath = (m_screenGrabDirectory == _T("") ? m_screenGrabDirectory : m_screenGrabDirectory + _T("\\"));
CString filename(filePath + newFilename + _T(".png"));
img.Attach(screenBitmap);
img.Save(filename);
img.Detach();
}
else
{
// Put bitmap on the clipboard.
//
::EmptyClipboard();
::SetClipboardData(CF_BITMAP, screenBitmap);
::CloseClipboard();
}
// Cleanup
//
::DeleteDC(screenDC);
MeaToolMgr::Instance().EnableRadioTool();
return 0;
}
示例14: LoadImage
//******************************************
HRESULT BMPanvas::LoadImage( CString name )
{
HRESULT ret;
CImage TI;
if((ret=TI.Load(name))==S_OK)
{
HDC thdc=TI.GetDC();
hdc=CreateCompatibleDC(thdc);
TI.ReleaseDC();
if(hdc!=NULL)
{
Attach(TI.Detach());
FileName=name;
}
}
return ret;
}
示例15: LoadImage
BOOL CEnBitmap::LoadImage(LPCTSTR szImagePath, COLORREF crBack)
{
ASSERT(m_hObject == NULL); // only attach once, detach on destroy
if (m_hObject != NULL)
return FALSE;
// If GDI+ is available, use that API because it supports more file formats and images with alpha channels.
// That DLL is installed with WinXP is available as redistributable from Microsoft for Win98+. As this DLL
// may not be available on some OS but we have to link statically to it, we have to take some special care.
//
extern bool g_bGdiPlusInstalled;
if (g_bGdiPlusInstalled)
{
CImage img;
if (SUCCEEDED(img.Load(szImagePath)))
{
CBitmap::Attach(img.Detach());
return TRUE;
}
}
BOOL bResult = FALSE;
CFile cFile;
CFileException e;
if (cFile.Open(szImagePath, CFile::modeRead | CFile::typeBinary | CFile::shareDenyWrite, &e))
{
int nSize = (int)cFile.GetLength();
BYTE* pBuff = new BYTE[nSize];
if (cFile.Read(pBuff, nSize) > 0)
{
IPicture* pPicture = LoadFromBuffer(pBuff, nSize);
if (pPicture)
{
bResult = Attach(pPicture, crBack);
pPicture->Release();
}
}
delete [] pBuff;
}
return bResult;
}