BOOL CStaffSetDlg::ShowPhoto(const CString& strPhotoPath, CWnd* pWnd) { POSITION pos=m_ListCtr_Staff.GetFirstSelectedItemPosition(); int index=m_ListCtr_Staff.GetNextSelectedItem(pos); SLZStaff staffinfo=m_List_StaffInfo.GetAt(m_List_StaffInfo.FindIndex(index)); CStatic* picPhoto = (CStatic*)pWnd; CDC* pDC = picPhoto->GetWindowDC(); CRect rect; picPhoto->GetClientRect(&rect); CImage img; if(strPhotoPath.IsEmpty()) { pDC->SelectStockObject(GRAY_BRUSH); pDC->FillRect( &rect, pDC->GetCurrentBrush()); UpdateData(FALSE); return FALSE; } HRESULT hResult = img.Load(strPhotoPath); if(FAILED(hResult)) { MessageBox(_T("图片路径错误,导入失败")); staffinfo.SetStaffPhoto(_T("")); m_ListCtr_Staff.SetItemText(index,4,_T("未配置")); m_List_StaffInfo.GetAt(m_List_StaffInfo.FindIndex(index))=staffinfo; return FALSE; } pDC->SetStretchBltMode(STRETCH_HALFTONE); img.Draw(pDC->m_hDC, 0, 0, rect.Width(), rect.Height(), 0, 0, img.GetWidth(), img.GetHeight()); //把图片填充在控件中 return TRUE; }
//加载图片 bool CImageEditorControl::LoadEditImage(LPCTSTR pszImage) { //加载图片 CImage ImageSource; if (ImageSource.Load(pszImage)!=S_OK) { //错误断言 ASSERT(FALSE); //事件通知 ASSERT(m_pIImageEditorEvent!=NULL); if (m_pIImageEditorEvent!=NULL) m_pIImageEditorEvent->OnEventImageSelect(false,false); return false; } //更新图片 if (LoadEditImage(ImageSource)==false) { ASSERT(FALSE); return false; } return true; }
void Cmp3taggerDlg::fillEditTextBoxes(Tag* tag) { this->UpdateData(); DeleteFile(L"tmppic"); theApp.editTitle = tag->GetTitleCString(); theApp.editArtist = tag->GetArtistCString(); theApp.editAlbum = tag->GetAlbumCString(); theApp.editYear = tag->GetYearCString(); theApp.editTrackNumber = tag->GetTrackCString(); theApp.editGenre = tag->GetGenreCString(); theApp.editAlbumArtist = tag->GetAlbumArtistCString(); theApp.editDiscNumber = tag->GetDiscNumberCString(); ASSERT_VALID(m_stCover); m_stCover.Invalidate(); m_stCover.UpdateWindow(); CImage img; tag->SaveCoverToFile("tmppic"); img.Load(_T("tmppic")); CDC *pdc = m_stCover.GetDC(); HDC hdc = pdc->GetSafeHdc(); SetStretchBltMode(hdc, HALFTONE); img.StretchBlt(hdc, 0, 0, 150, 150); this->UpdateData(FALSE); }
void CMesh::CreateTerrainFromHeightMap( float sx, float sy, float tex_nx, float tex_ny, const char *heightmap_file_name, float height_offset, float height_scaling) { // 载入高度图 CImage img; if (!img.Load(heightmap_file_name)) return; int nx=img.width-1; // x方向细分数 int ny=img.height-1; // y方向细分数 // 构造长方形网格 CreateRectangle(sx, sy, nx, ny, tex_nx, tex_ny); // 设置顶点高度 int i, n=(nx+1)*(ny+1); for (i=0; i<n; ++i) { float h=(float)img.pixels[i*img.bpp]; vertices[i].position.z=height_scaling*h+height_offset; } // 计算顶点平均法线 CalculateVertexAverageNormals(); }
bool CThirdoneDlg::Show_picture(CString imgPath) { int height, width; CRect rect;//定义矩形类 CRect rect1; CImage image; //创建图片类 image.Load(imgPath); height = image.GetHeight(); width = image.GetWidth(); this->GetClientRect(&rect); //获得pictrue控件所在的矩形区域 CDC *pDc = this->GetDC();//获得pictrue控件的Dc SetStretchBltMode(pDc->m_hDC,STRETCH_HALFTONE); xScale=(float)rect.Width()/(float)width; yScale=(float)rect.Height()/(float)height; if(width<=rect.Width() && height<=rect.Width()) //小图片,不缩放 { rect1 = CRect(rect.TopLeft(), CSize(width,height)); image.StretchBlt(pDc->m_hDC,rect,SRCCOPY); //将图片画到Picture控件表示的矩形区域 return TRUE; } else { xScale=(float)rect.Width()/(float)width; yScale=(float)rect.Height()/(float)height; float ScaleIndex=(xScale<=yScale?xScale:yScale); rect1 = CRect(rect.TopLeft(), CSize((int)width*ScaleIndex,(int)height*ScaleIndex)); image.StretchBlt(pDc->m_hDC,rect,SRCCOPY); //将图片画到Picture控件表示的矩形区域 } ReleaseDC(pDc);//释放picture控件的Dc return TRUE; }
bool cdr_thumbnail_png(const char* cdr_filename, const char* png_filename) { char bmp_filename[MAX_PATH] = {0}; if (png_filename == NULL) { char tmp_filename[MAX_PATH] = {0}; png_filename = tmp_filename; strcpy(tmp_filename , cdr_filename); strcpy(strrchr(tmp_filename, '.') , ".png"); } strcpy(bmp_filename , png_filename); strcpy(strrchr(bmp_filename, '.') , ".bmp"); // printf("%s\t\%s\n", bmp_filename , png_filename); bool ret = cdr_extract_bmp(cdr_filename , bmp_filename); if (!ret) return false ; CImage image; // bmp 转换 png ,需要CImage类,头文件 atlimage.h image.Load(bmp_filename); image.Save(png_filename); if (remove(bmp_filename) != 0) perror("Error deleting file"); return ret; }
//绘画头像 void CExpression::DrawItem(CDC * pDC, int iXPos, int iYPos, bool bSelectec) { CExpressionItem * pExpressionItem=GetExpressItem(iYPos*m_wMaxRow+iXPos); int nFaceIndex = iYPos*m_wMaxRow+iXPos; if (pExpressionItem!=NULL) { if (bSelectec) { pDC->FillSolidRect(iXPos*(EP_PIC_WHIDE+PIC_SPACE)+PIC_SPACE/2,iYPos*(EP_PIC_HIGHT+PIC_SPACE)+PIC_SPACE/2, EP_PIC_WHIDE+PIC_SPACE,EP_PIC_HIGHT+PIC_SPACE,RGB(255,255,255)); pDC->Draw3dRect(iXPos*(EP_PIC_WHIDE+PIC_SPACE)+PIC_SPACE/2,iYPos*(EP_PIC_HIGHT+PIC_SPACE)+PIC_SPACE/2, EP_PIC_WHIDE+PIC_SPACE,EP_PIC_HIGHT+PIC_SPACE,RGB(28,57,208),RGB(28,57,208)); } else { pDC->FillSolidRect(iXPos*(EP_PIC_WHIDE+PIC_SPACE)+PIC_SPACE/2,iYPos*(EP_PIC_HIGHT+PIC_SPACE)+PIC_SPACE/2, EP_PIC_WHIDE+PIC_SPACE,EP_PIC_HIGHT+PIC_SPACE,RGB(255,255,255)); } //装载图片 TCHAR szFileName[MAX_PATH]=TEXT(""); _snprintf(szFileName,sizeof(szFileName),TEXT("%s\\Face\\%d.gif"),m_szPath, nFaceIndex); CImage ImageFace; if ( SUCCEEDED(ImageFace.Load(szFileName) ) ) { //背景判断 COLORREF rfColor = ImageFace.GetPixel(0,0); TransparentBlt(pDC->GetSafeHdc(), iXPos*(EP_PIC_WHIDE+PIC_SPACE)+PIC_SPACE,iYPos*(EP_PIC_HIGHT+PIC_SPACE)+PIC_SPACE, EP_PIC_WHIDE, EP_PIC_HIGHT, ImageFace.GetDC(), 0, 0, EP_PIC_WHIDE, EP_PIC_HIGHT, rfColor); ImageFace.ReleaseDC(); } } return; }
int HTMLImage(EE_Context* pContext, LPRECT lpRect, LPCTSTR lpText) { CFileDialog dlg(FALSE, NULL, NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, _T("Image Files(*.jpg;*.jpeg;*.jpe;*.png;*.gif;*.bmp)\0*.jpg;*.jpeg;*.jpe;*.png;*.gif;*.bmp\0All Files(*.*)\0*.*\0\0")); if( dlg.DoModal(pContext->hMain)==IDOK ) { int w=-1; int h=-1; CImage img; if( img.Load( dlg.m_szFileName )==S_OK ) { w=img.GetWidth(); h=img.GetHeight(); img.Destroy(); } CString strText; if( w!=-1 ) strText.Format(_T("<img src=\"%s\" width=\"%d\" height=\"%d\" border=\"0\" alt=\"$0\">"), dlg.m_szFileName, w, h); else strText.Format(_T("<img src=\"%s\" width=\"\" height=\"\" border=\"0\" alt=\"$0\">"), dlg.m_szFileName); HWND hWnd=(HWND)::SendMessage(pContext->hMain, EEM_GETACTIVETEXT, 0, 0); if( hWnd ) ::SendMessage(hWnd, ECM_INSERTSNIPPET, (WPARAM)(LPCTSTR)strText, strText.GetLength()); } return 0; }
void CMapDetail::initMapDetail( const CString& strPrev, int nNum ) { for( int i=1; i <= nNum; ++i ) { CString strTemp; strTemp.Format( "%s_%d.png", strPrev, i ); CString strPath; strPath.Format( "./Editor/mapStyle/%s_%d.png", strPrev, i ); std::string strFileName = strTemp.GetBuffer(); CImage* pImage = new CImage; pImage->Load( strPath ); ImageInfo ii; ii.pImage = pImage; ii.nWidth = pImage->GetWidth(); ii.nHeight = pImage->GetHeight(); ii.nOffsetX = 0; ii.nOffsetY = 0; m_mapImages[strFileName] = ii; } adjustLayout(); }
void LoadTexture(Gfx::CGLDevice *device, const std::string &name) { if (name.empty()) return; Gfx::Texture tex = GetTexture(name); if (tex.Valid()) return; CImage img; if (! img.Load(std::string("tex/") + name)) { std::string err = img.GetError(); GetLogger()->Error("Texture not loaded, error: %s!\n", err.c_str()); } else { Gfx::TextureCreateParams texCreateParams; texCreateParams.mipmap = true; texCreateParams.minFilter = Gfx::TEX_MIN_FILTER_LINEAR_MIPMAP_LINEAR; texCreateParams.magFilter = Gfx::TEX_MAG_FILTER_LINEAR; tex = device->CreateTexture(&img, texCreateParams); } TEXS[name] = tex; }
GLuint ATLLoadTexture(const char *fileName) { BITMAP bm; GLuint idTexture = 0; CImage img; //需要头文件atlimage.h HRESULT hr = img.Load(fileName); if (!SUCCEEDED(hr)) //文件加载失败 { MessageBox(NULL, "文件加载失败", "ERROR", 0); return NULL; } HBITMAP hbmp = img; if (!GetObject(hbmp, sizeof(bm), &bm)) return 0; glGenTextures(1, &idTexture); if (idTexture) { glBindTexture(GL_TEXTURE_2D, idTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glPixelStoref(GL_PACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, 0, 3, bm.bmWidth, bm.bmHeight, 0, GL_BGR, GL_UNSIGNED_BYTE, bm.bmBits); //这里不是GL_RGB } return idTexture; }
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); }
void CHMMDemoDoc::AddObj( CImage& img, CRect roi, CStringList* otherImages ) { CImageBaseView* view = GetImageBaseView(); if( view ) { int new_person_index = 0; int index = view->GetPersonIndex(); CPerson* person = 0; if( index < 0 ) // no person selected { person = AskPersonName(); if( !person ) return; new_person_index = m_base.GetPersonIndex( person ); } else { person = GetFaceBase().GetPerson(index); if( !person ) { ASSERT( 0 ); return; } } person->AddImage( 0, &img, roi ); if( otherImages ) { POSITION pos = otherImages->GetHeadPosition(); //skip first image, bacause it have already beeb added otherImages->GetNext( pos ); while( pos ) { CString path = otherImages->GetNext(pos); char drive[1024], dir[1024]; _splitpath( path, drive, dir, 0, 0 ); strcat( drive, dir ); if( _stricmp( drive, person->GetFolder()) == 0 ) { person->AddImage( path, 0, CRect(0,0,0,0)); } else { CImage img; img.Load( path, 0 ); person->AddImage( 0, &img, CRect(0,0,0,0)); } } } if( index >= 0 ) view->RefreshView(); else view->SwitchMode( new_person_index, true ); } }
HBITMAP LoadBmpFromImageFile(LPCTSTR lpszFileName) { HBITMAP hBitmap = NULL; //Gdiplus::Bitmap bmp(lpszFileName, false); CImage image; image.Load(lpszFileName); hBitmap = image.Detach(); return hBitmap; }
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; }
int DjvuPic::SetBuffer(CString& fullName,bool check) { int err=ERR_OK; Buffer->Destroy(); Buffer->Create(Parent, Foreground->INFO.bmiHeader.biWidth, Foreground->INFO.bmiHeader.biHeight, 8); Buffer->CreateGrayPallete(); CImage TT; TT.Load(FrgFile); TT.BitBlt(Buffer->GetDC(),0,0); return err; }
//绘画头像 void __cdecl CUserFaceRes::DrawNormalFace(CDC * pDC, int nXPos, int nYPos, WORD wFaceID, DWORD dwUserID, DWORD dwCustomFace) { //调整参数 if (wFaceID>=m_wCount) wFaceID=0; //绘画头像 CDC DCFace; DCFace.CreateCompatibleDC(NULL); DCFace.SelectObject(m_NormalFace); bool bDrawFace = false; if(dwCustomFace!=0) { //头像名称 CString strDirName; strDirName.Format(TEXT("%s\\CustomFace"),m_szDirWork); CString strFileName; strFileName.Format(TEXT("\\%ld_%d.bmp"), dwUserID, dwCustomFace); //读取文件 CImage FaceImage; HRESULT hResult = FaceImage.Load(strDirName + strFileName); if (SUCCEEDED(hResult)) { //设置模式 int nOldBltMode = pDC->SetStretchBltMode(HALFTONE); //设置大小 CRect rcFace; rcFace.left = nXPos; rcFace.top = nYPos; rcFace.right = rcFace.left + m_NormalSize.cx; rcFace.bottom = rcFace.top + m_NormalSize.cy; //绘画图片 FaceImage.StretchBlt(pDC->GetSafeHdc(), rcFace); //删除资源 pDC->SetStretchBltMode(nOldBltMode); FaceImage.Destroy(); bDrawFace=true; } } //正常头像 if(!bDrawFace) { m_HeadImage.DrawImage(pDC, nXPos, nYPos, m_NormalSize.cx,m_NormalSize.cy, wFaceID*m_NormalSize.cx, 0, m_NormalSize.cx,m_NormalSize.cy); //AlphaDrawImage(pDC,nXPos,nYPos,m_NormalSize.cx,m_NormalSize.cy,&DCFace,wFaceID*m_NormalSize.cx,0); } return; }
void DrawImage(HWND hParentWnd, CTSTR wszImage, int nResourceID) { CImage *pImage = new CImage; pImage->Load(wszImage); //pImage->Load(L"D:\\sss.jpg"); HWND hwndPicZone = GetDlgItem(hParentWnd, nResourceID); RECT rect; GetClientRect(hwndPicZone, &rect); pImage->Draw(GetDC(hwndPicZone), rect); delete pImage; }
CImage* CTracer::LoadImageFromFile(std::string fileName) { CImage* pImage = new CImage; if(SUCCEEDED(pImage->Load(fileName.c_str()))) return pImage; else { delete pImage; return NULL; } }
MulRect CPicDlgQuery::GetWidthHeight(const string& path) { CImage img; HRESULT hr = img.Load(CCharset::AnsiToUnicode(path).c_str()); if (hr == S_OK) { MulRect rect = { 0, 0, img.GetWidth(), img.GetHeight() }; img.Destroy(); return rect; } return MulRect(); }
// 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; }
bool LoadPNG(LPCTSTR pszImageName, CImage& Image) { if (pszImageName == NULL || ((HBITMAP) Image) != NULL) return false; // get the instance handle for loading the resource HINSTANCE hInst = ::AfxGetInstanceHandle(); // find the resource HRSRC hRes = ::FindResource(hInst, pszImageName, _T("png")); if (hRes == NULL) return false; // load the resource HGLOBAL hLoadedImage = ::LoadResource(hInst, hRes); if (hLoadedImage == NULL) return false; bool bStatus = false; // get a pointer to the bitmap void* pSrcImageData = ::LockResource(hLoadedImage); if (pSrcImageData != NULL) { // get the size of the resource since we need to load it into memory DWORD dwImageSize = ::SizeofResource(hInst, hRes); // allocate memory for the bitmap HGLOBAL hDestImageData = ::GlobalAlloc(GMEM_MOVEABLE, dwImageSize); if (hDestImageData != NULL) { // create an IStream to allow us to load the bitmap CComPtr<IStream> pImageStream; HRESULT hr = ::CreateStreamOnHGlobal(hDestImageData, TRUE, &pImageStream); if (hr == S_OK) { // write the data into the stream ULONG nWritten = 0; hr = pImageStream->Write(pSrcImageData, dwImageSize, &nWritten); // load the bitmap now if (Image.Load(pImageStream) == S_OK) { bStatus = true; } } } } ::UnlockResource(hLoadedImage); return bStatus; }
void show_avator(CString strFilePath,CStatic *m_pic) { CImage *pImage = new CImage(); HRESULT ret = pImage->Load(strFilePath); if (FAILED(ret)) return; CRect rect; m_pic->GetWindowRect(rect); CDC* pDC = m_pic->GetWindowDC(); SetStretchBltMode(pDC->m_hDC, STRETCH_HALFTONE); pImage->StretchBlt(pDC->m_hDC, 0, 0, rect.Width(), rect.Height()); pImage->Draw(pDC->m_hDC, rect); }
FTL::FileFindResultHandle CLotteryMgr::OnFindFile(LPCTSTR pszFilePath, const WIN32_FIND_DATA& findData, LPVOID pParam) { HRESULT hr = E_FAIL; BOOL bRet = FALSE; Gdiplus::Status sts = Gdiplus::Ok; if (ftwtContinue != m_threadInit.GetThreadWaitType(INFINITE)) { return rhStop; } if ((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) { //find result file FTLTRACE(TEXT("OnFindFile: %s\n"), pszFilePath); CImage img; COM_VERIFY(img.Load(pszFilePath)); if (SUCCEEDED(hr)) { LotteryInfoPtr pLotteryInfo(new LotteryInfo(pszFilePath, FALSE)); CRect rcThumbnail(0, 0, m_szThumbnail.cx, m_szThumbnail.cy); CSize szImage(img.GetWidth(), img.GetHeight()); CRect rcDrawTarget = m_pCalcRect->GetFitRect(rcThumbnail, szImage); if (rcDrawTarget.bottom <= rcDrawTarget.top) { rcDrawTarget.bottom = rcDrawTarget.top + 1; } if (rcDrawTarget.right <= rcDrawTarget.left) { rcDrawTarget.right = rcDrawTarget.left + 1; } API_VERIFY(pLotteryInfo->imgThumbnail.Create(rcDrawTarget.Width(), rcDrawTarget.Height(), 32, CImage::createAlphaChannel)); if (bRet) { CImageDC dc(pLotteryInfo->imgThumbnail); Gdiplus::Bitmap bmp((HBITMAP)img, NULL); Gdiplus::Graphics graphic(dc); GDIPLUS_VERIFY(graphic.DrawImage(&bmp, 0, 0, rcDrawTarget.Width(), rcDrawTarget.Height())); SendMessage(m_hWndControl, UM_ADD_LOTTERY_INFO, (WPARAM)pLotteryInfo.get(), NULL); m_allLotteryInfos.push_back(pLotteryInfo); } } } return rhContinue; }
void CInsertDlg::drawpic() { CRect rectPic; m_pic.GetClientRect(&rectPic); //m_picture为Picture Control控件变量,获得控件的区域对象 CDC* pDC = m_pic.GetWindowDC(); //获得显示控件的DC CImage *pImage = new CImage(); //装载图像的类 int n = all; if (cur< n){ //还有图片可以显示 HRESULT ret; CString path = CString(setting.libpath.c_str()) + CString("\\") + CString(album.record(fileno[cur]).filename().c_str()); ret = pImage->Load(path);//从磁盘装载图片,根据页面计算得到的图片下标 if (FAILED(ret)){ MessageBox(path + _T("不存在!")); return; } int width = rectPic.Width(); //显示区域的宽和高 int height = rectPic.Height(); int picW = pImage->GetWidth(); //图片的宽和高 int picH = pImage->GetHeight(); //计算缩放比 double r1 = double(picW) / double(width); double r2 = double(picH) / double(height); //r为最优缩放比例 double r = (r1 >= r2 ? r1 : r2); int w = picW / r; int h = picH / r; int sw = (width - w) / 2; int sh = (height - h) / 2; //防止缩放后失真 SetStretchBltMode(pDC->m_hDC, HALFTONE); //SetBrushOrgEx(pDC->m_hDC, 0, 0, NULL); pImage->StretchBlt(pDC->m_hDC, sw, sh, w, h); //显示图片 pImage->Draw(pDC->m_hDC, sw, sh, w, h); ReleaseDC(pDC); delete pImage; } else{ m_pic.ShowWindow(SW_HIDE); } }
DLLEXP bool load(WCHAR *fn) { CImage ci; HRESULT hr=ci.Load(fn); if (!SUCCEEDED(hr)) { return false; } g_snap_height=ci.GetHeight(); g_snap_width=ci.GetWidth(); BitBlt(g_memdc.m_hDC,0,0,g_snap_width,g_snap_height,ci.GetDC(),0,0,SRCCOPY); g_bitmap.GetBitmapBits(g_scn_height*g_scn_width*4,g_buf_clr); return true; }
// 从文件加载图片 BOOL ReadImage(const CString& path, Mat& img) { img = cv::imread((LPCSTR)(CStringA)path); if (img.data != NULL) return TRUE; // 加载OpenCV不支持的格式(GIF) CImage image; image.Load(path); if (image.IsNull()) return FALSE; return CImageToMat(image, img); }
CImage *AquireImage( HINSTANCE hInstance, LPCTSTR pcszFilePath, LPCTSTR pcszFilename ) { CImage *pImage = NULL; // // Check for resource based images if( !_tcsnicmp( pcszFilename, _T("RES:"), 4 ) ) { pcszFilename += 4; ASSERT( _tcslen( pcszFilename ) ); pImage = new CImage; if( !pImage->Load( hInstance, pcszFilename ) ) { LPTSTR endptr; if( !pImage->Load( hInstance, MAKEINTRESOURCE( _tcstol( pcszFilename, &endptr, 10 ) ) ) ) { delete pImage; pImage = NULL; } } return pImage; } // // Check for file based images StringClass strImageName( pcszFilePath ); strImageName += pcszFilename ; pImage = new CImage; if( !pImage->Load( strImageName ) ) { delete pImage; pImage = NULL; } return pImage; }
void CChildView::OnPaint() { CPaintDC dc(this); // device context for painting // 로드된 이미지 CImage img; LPCTSTR imgPath = imgpath_; img.Load(imgPath); // 화면 DC에 출력 if(img != NULL) { img.BitBlt(dc.m_hDC, 0, 0); } else { return; } }
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]); }