bool SmtSmfRasLayer::Fetch(eSmtFetchType type) { if (!IsOpen()) return false; char szImgUrl[MAX_LAYER_FILE_NAME]; SmtDataSourceInfo info; m_pOwnerDs->GetInfo(info); sprintf(szImgUrl,"%s",m_szLayerFileName); long lCodeType = GetImageTypeByFileExt(m_szLayerFileName); CxImage img; if (img.Load(szImgUrl,lCodeType)) { BYTE *pImageBuf = NULL; long lImageBufSize = 0; fRect fLocRect; m_pMemLayer->GetRasterRect(fLocRect); fLocRect.rt.y = fLocRect.lb.y + fLocRect.Width()*img.GetHeight()/img.GetWidth(); if (img.Encode(pImageBuf,lImageBufSize,lCodeType)) { return (SMT_ERR_NONE == m_pMemLayer->CreaterRaster((const char *)pImageBuf,lImageBufSize,fLocRect,lCodeType)); } } return false; }
bool IGFrame::Update() { if (!UpdateSize (head.biWidth, head.biHeight)) return false; // update selection rect RECT rcSel = {0, 0, -1, -1}; CxImage *pLayer = GetWorkingLayer(); if (pLayer->SelectionIsValid()) pLayer->SelectionGetBox (rcSel); if (rcSel.right != -1 && rcSel.bottom != -1){ long nOffsetX, nOffsetY; pLayer->GetOffset (&nOffsetX, &nOffsetY); rcSel.left += nOffsetX; rcSel.right += nOffsetX; rcSel.top -= nOffsetY; rcSel.bottom -= nOffsetY; } wchar_t twLeft [32], twRight [32], twTop [32], twBottom [32]; ::_itow (rcSel.left, twLeft, 10); ::_itow (rcSel.right, twRight, 10); ::_itow (rcSel.top, twTop, 10); ::_itow (rcSel.bottom, twBottom, 10); wstring wsSelRect (twLeft); wsSelRect += L"#"; wsSelRect+= twRight; wsSelRect += L"#"; wsSelRect+= twTop; wsSelRect += L"#"; wsSelRect+= twBottom; SetProperty (IGFRAMEPROPERTY_SELECTIONRECT, wsSelRect); // update current history step id SetProperty (IGFRAMEPROPERTY_HISTORYSTEP, GetCurrentStepId()); return true; }
int IGIPDraw::GetSecondParam (IGImageProcMessage& message, CxImage& image) const { IGIPDrawMessage *pIGThreadMessage = dynamic_cast <IGLibrary::IGIPDrawMessage *> (&message); if (!pIGThreadMessage) return false; RECT *prcSubLayer = (RECT*)IGIPFilter::GetSecondParam (message, image); if (!prcSubLayer) return false; int nLayerWidth = image.GetWorkingLayer()->GetWidth(); int nLayerHeight = image.GetWorkingLayer()->GetHeight(); RECT rcDraw = IGConvertible::FromListPtsToRECT (pIGThreadMessage->m_lPts, nLayerWidth, nLayerHeight); int nTop = rcDraw.top; rcDraw.top = nLayerHeight - 1 - rcDraw.bottom; // convert to Cx Coords rcDraw.bottom = nLayerHeight - 1 - nTop; // enlarge the region with the brush size + 1 in every direction int nOffsetSize = (int)pIGThreadMessage->m_pBrush->GetSize() + 1; rcDraw.left = max (0, rcDraw.left - nOffsetSize); rcDraw.right = min (nLayerWidth - 1, rcDraw.right + nOffsetSize); rcDraw.top = max (0, rcDraw.top - nOffsetSize); rcDraw.bottom = min (nLayerHeight - 1, rcDraw.bottom + nOffsetSize); if ((prcSubLayer->bottom != -1) && (prcSubLayer->right != -1)) { prcSubLayer->left = max (prcSubLayer->left, rcDraw.left); prcSubLayer->right = min (prcSubLayer->right, rcDraw.right); prcSubLayer->top = max (prcSubLayer->top, rcDraw.top); prcSubLayer->bottom = min (prcSubLayer->bottom, rcDraw.bottom); } else { *prcSubLayer = rcDraw; } return (int)prcSubLayer; }
bool CDemoView::SetImageRectSelection(CDemoDoc *pDoc,CRect *rect) { if (pDoc==0) return false; CxImage* ima = pDoc->GetImage(); if (ima==0) return false; long x,y; RECT rect_img; x = rect_img.left = rect->left; y = rect_img.top = rect->top; GetImageXY(pDoc, ima, &x,&y); rect_img.top = ima->GetHeight() - 1 - y; rect_img.left = x; x = rect_img.right = rect->right; y = rect_img.bottom = rect->bottom; GetImageXY(pDoc, ima, &x,&y); rect_img.bottom = ima->GetHeight() - 1 - y; rect_img.right = x; ima->SelectionClear(); ima->SelectionAddRect(rect_img); return true; }
HRESULT IGFrame::Resample (long newx, long newy, IGFRAMEPROPERTY_STRETCHING_ENUM eStretchMode) { // Request thread access if (!RequestAccess ()) return E_ACCESSDENIED; HRESULT hRes = E_NOTIMPL; CxImage *pCurrentLayer = GetWorkingLayer(); if (!pCurrentLayer) return false; pCurrentLayer->SelectionDelete(); switch (eStretchMode) { case IGFRAMEPROPERTY_STRETCHING_NO: hRes = resampleNoStretch (newx, newy); break; case IGFRAMEPROPERTY_STRETCHING_BICUBIC: hRes = resampleBicubic (newx, newy); break; case IGFRAMEPROPERTY_STRETCHING_FAST: hRes = resampleFast (newx, newy); break; } if (SUCCEEDED (hRes)) SetSize (newx, newy); return hRes; }
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); } }
BOOL ScreenSnapshot::saveRect(__in RECT &rc, __in std::wstring &savePath) { snapshotScreen(); CxImage img; int cx = rc.right - rc.left; int cy = rc.bottom - rc.top; HDC hSaveDC = CreateCompatibleDC(m_hMemDC); HBITMAP hBitmap = CreateCompatibleBitmap(m_hMemDC, cx, cy); HBITMAP hSaveBitmap = (HBITMAP)SelectObject(hSaveDC, (HGDIOBJ)hBitmap); BitBlt(hSaveDC, 0, 0, cx, cy, m_hMemDC, rc.left, rc.top, SRCCOPY); hBitmap = (HBITMAP)SelectObject(hSaveDC, (HBITMAP)hSaveBitmap); BOOL result = FALSE; do { if (!img.CreateFromHBITMAP(hBitmap)) { break; } if (!img.Save(savePath.c_str(), CXIMAGE_FORMAT_BMP)) { break; } result = TRUE; } while (FALSE); DeleteObject((HGDIOBJ)hBitmap); DeleteDC(hSaveDC); return result; }
bool CImageSelect::SetImageRectSelection(CRect *rect) { CxImage* ima = ℑ if (ima==0) return false; long x,y; RECT rect_img; x = rect_img.left = rect->left-(500-(int)(image.GetWidth()*ZoomFactor))/2; y = rect_img.top = rect->top-(300-(int)(image.GetHeight()*ZoomFactor))/2; GetImageXY(ima, &x,&y); rect_img.top = y; rect_img.left = x; x = rect_img.right = rect->right-(500-(int)(image.GetWidth()*ZoomFactor))/2; y = rect_img.bottom = rect->bottom-(300-(int)(image.GetHeight()*ZoomFactor))/2; GetImageXY(ima, &x,&y); rect_img.bottom = y; rect_img.right = x; ima->SelectionClear(); ima->SelectionAddRect(rect_img); ima->Crop(rect_img,&NewImage); return true; }
bool IGFrameManager::Cut(LPCWSTR pcwGuid) { IGSmartPtr <IGFrame> spFrame; if (!GetFrame(pcwGuid, spFrame)) return false; CxImage *pCxLayer = spFrame->GetWorkingLayer(); if (!pCxLayer) return false; RECT rcSel; if (pCxLayer->SelectionIsValid()) pCxLayer->SelectionGetBox (rcSel); else{ rcSel.bottom = 0; rcSel.left = 0; rcSel.top = pCxLayer->GetHeight(); rcSel.right = pCxLayer->GetWidth(); } m_spClipboardLayer = new IGLayer(NULL); m_spClipboardLayer->Create (rcSel.right - rcSel.left, rcSel.top - rcSel.bottom, 24); m_spClipboardLayer->AlphaCreate(); pCxLayer->AlphaCreate(); RGBQUAD qGray; qGray.rgbBlue = CXIMAGE_GRAY; qGray.rgbGreen = CXIMAGE_GRAY; qGray.rgbRed = CXIMAGE_GRAY; for(long y=rcSel.bottom; y<rcSel.top; y++){ for(long x=rcSel.left; x<rcSel.right; x++){ if (pCxLayer->BlindSelectionIsInside(x,y)){ m_spClipboardLayer->BlindSetPixelColor(x - rcSel.left, y - rcSel.bottom, pCxLayer->BlindGetPixelColor(x,y)); pCxLayer->BlindSetPixelColor(x, y, qGray); pCxLayer->AlphaSet(x, y, 0); } else m_spClipboardLayer->AlphaSet (x - rcSel.left, y - rcSel.bottom, 0); } } return true; }
int IGIPFilter::GetFirstParam (IGImageProcMessage& message, CxImage& image) const { IGIPFilterMessage *pIGThreadMessage = dynamic_cast <IGLibrary::IGIPFilterMessage *> (&message); if (!pIGThreadMessage) return false; return (int)image.GetLayerPos (image.GetWorkingLayer()); }
//鼠标在窗口上移动时需要进行的更新 void CEmotionButton::UpdateSelectedFace(int curPage, int curSel, int curFrame, int pvstatus) { HGDIOBJ hOldBrush = NULL, hOldPen = NULL, hTempPen, hTempBrush; HPEN hPen1 = NULL; HPEN hPen2 = NULL; LPRECT lpRect = NULL; RECT rc; int index; //贴背景 BitBlt(m_hMemDC, 0, 0, QQFACEDLG_WIDTH, QQFACEDLG_HEIGHT, m_hMemDCBkGnd, 0, 0, SRCCOPY); //绘制蓝色选中框 if(curSel >= 0) { hPen1 = CreatePen(PS_SOLID, 1, RGB(0, 0, 255)); hTempPen = SelectObject(m_hMemDC, hPen1); hTempBrush = SelectObject(m_hMemDC, GetStockObject(NULL_BRUSH)); GetBlueRect(curSel, &rc); Rectangle(m_hMemDC, rc.left, rc.top, rc.right, rc.bottom); if(hOldPen == NULL) hOldPen = hTempPen; if(hOldBrush == NULL) hOldBrush = hTempBrush; } //绘制左侧或者右侧的预览图 if(pvstatus == _PVStatus::Left) lpRect = &rcLeft; else if(pvstatus == _PVStatus::Right) lpRect = &rcRight; if(lpRect != NULL) { index = curPage * CELLCOUNT_PAGE + curSel; //从页内相对索引计算出绝对索引。 hPen2 = CreatePen(PS_SOLID, 1, RGB(0, 138, 255)); //淡蓝色画笔 hTempPen = SelectObject(m_hMemDC, hPen2); hTempBrush = SelectObject(m_hMemDC, GetStockObject(WHITE_BRUSH)); //白色画刷 Rectangle(m_hMemDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); //居中绘制 int left = (lpRect->left + lpRect->right - m_CxImages[index].GetWidth())/2; int top = (lpRect->top + lpRect->bottom - m_CxImages[index].GetHeight())/2; //设置帧 if(curFrame < m_CxImages[index].GetNumFrames()) { CxImage* pFrame = m_CxImages[index].GetFrame(curFrame); if(pFrame) pFrame->Draw(m_hMemDC, left, top); //m_CxImages[index].Draw(m_hMemDC, left, top); } if(hOldBrush == NULL) hOldBrush = hTempBrush; if(hOldPen == NULL) hOldPen = hTempPen; } //恢复画刷,画笔 if(hOldBrush != NULL) SelectObject(m_hMemDC, hOldBrush); if(hOldPen != NULL) SelectObject(m_hMemDC, hOldPen); if(hPen1 != NULL) DeleteObject(hPen1); if(hPen2 != NULL) DeleteObject(hPen2); }
__declspec(dllexport) bool LoadImage(const char *file, unsigned int maxwidth, unsigned int maxheight, ImageInfo *info) { if (!file || !info) return false; if (IsDir(file)) return false; // load the image DWORD dwImageType = GetImageType(file); CxImage *image = new CxImage(dwImageType); if (!image) return false; int actualwidth = maxwidth; int actualheight = maxheight; try { if (!image->Load(file, dwImageType, actualwidth, actualheight) || !image->IsValid()) { #if !defined(_LINUX) && !defined(__APPLE__) int nErr = GetLastError(); #else int nErr = errno; #endif printf("PICTURE::LoadImage: Unable to open image: %s Error:%s (%d)\n", file, image->GetLastError(),nErr); delete image; return false; } } catch (...) { printf("PICTURE::LoadImage: Unable to open image: %s\n", file); delete image; return false; } // ok, now resample the image down if necessary if (ResampleKeepAspect(*image, maxwidth, maxheight) < 0) { printf("PICTURE::LoadImage: Unable to resample picture: %s\n", file); delete image; return false; } // make sure our image is 24bit minimum image->IncreaseBpp(24); // fill in our struct info->width = image->GetWidth(); info->height = image->GetHeight(); info->originalwidth = actualwidth; info->originalheight = actualheight; memcpy(&info->exifInfo, image->GetExifInfo(), sizeof(EXIFINFO)); // create our texture info->context = image; info->texture = image->GetBits(); info->alpha = image->AlphaGetBits(); return (info->texture != NULL); };
int ResampleKeepAspectArea(CxImage &image, unsigned int area) { float fAspect = ((float)image.GetWidth()) / ((float)image.GetHeight()); unsigned int width = (unsigned int)sqrt(area * fAspect); unsigned int height = (unsigned int)sqrt(area / fAspect); if (width > MAX_WIDTH) width = MAX_WIDTH; if (height > MAX_HEIGHT) height = MAX_HEIGHT; return ResampleKeepAspect(image, width, height, true); }
CxImage* CFeedIcoItemListCtrl::GetPng(LPCTSTR lpszPngResource) { if (NULL == lpszPngResource) return NULL; CxImage* image = new CxImage(CXIMAGE_FORMAT_PNG); image->LoadResource(FindResource(NULL, lpszPngResource, _T("PNG")), CXIMAGE_FORMAT_PNG); return image; }
CxImage* loadImage(const char* imagePath, DWORD imageType) { CxImage* image = new CxImage; if (!image->Load(imagePath, imageType)) { printf("get image error!\n"); return NULL; } return image; }
CxImage* IGFrame::GetSelectionLayer() { for (int nIdxItem = 0; nIdxItem < GetNbLayers(); nIdxItem++) { CxImage *pLayer = GetLayer(nIdxItem); if (pLayer->SelectionIsValid()) return pLayer; } return NULL; }
HBITMAP CSkin::LoadImage(const char *filename) { CxImage image; image.Load(filename); if(!image.IsValid()) { return NULL; } return image.MakeBitmap(NULL); }
bool CPicShowCtrl::SaveFile(CString strPath) { int width=180; int height=180; CPaintDC dc(this); CxImage img; img.CreateFromHBITMAP(m_hBmp); CBitmap bitmapmem; CBitmap *pOldBit; CDC m_pMemDC; m_pMemDC.CreateCompatibleDC(&dc); bitmapmem.CreateCompatibleBitmap(&dc, width, height); pOldBit=m_pMemDC.SelectObject(&bitmapmem); CRect rect(0,0,width,height); HBRUSH bgBrush = ::CreateSolidBrush(RGB(255,255,255)); FillRect(m_pMemDC,&rect,bgBrush); DeleteObject(bgBrush); img.Draw(m_pMemDC,m_iStartx,m_iStarty,img.GetWidth(),img.GetHeight(),&rect); CBitmap* pBmp=m_pMemDC.SelectObject(pOldBit); CxImage xImagebmp; xImagebmp.CreateFromHBITMAP((HBITMAP)bitmapmem.m_hObject); xImagebmp.Resample(100,100,0); bitmapmem.DeleteObject(); m_pMemDC.DeleteDC(); if(xImagebmp.Save(common::utility::stringhelper::UnicodeToAscii(strPath.GetBuffer()).c_str(), CXIMAGE_FORMAT_JPG)) { return true; } return false; }
void CCaptchaGenerator::ReGenerateCaptcha(uint32 nLetterCount) { Clear(); CxImage* pimgResult = new CxImage(nLetterCount > 1 ? (LETTERSIZE + (nLetterCount-1)*CROWDEDSIZE) : LETTERSIZE, 32, 1, CXIMAGE_FORMAT_BMP); pimgResult->SetPaletteColor(0, 255, 255, 255); pimgResult->SetPaletteColor(1, 0, 0, 0, 0); pimgResult->Clear(); CxImage imgBlank(LETTERSIZE, LETTERSIZE, 1, CXIMAGE_FORMAT_BMP); imgBlank.SetPaletteColor(0, 255, 255, 255); imgBlank.SetPaletteColor(1, 0, 0, 0, 0); imgBlank.Clear(); for (uint32 i = 0; i < nLetterCount; i++) { CxImage imgLetter(imgBlank); CString strLetter(schCaptchaContent[GetRandomUInt16() % ARRSIZE(schCaptchaContent)]); m_strCaptchaText += strLetter; uint16 nRandomSize = GetRandomUInt16() % 10; uint16 nRandomOffset = 3 + GetRandomUInt16() % 11; imgLetter.DrawString(NULL, nRandomOffset, 32, strLetter, imgLetter.RGBtoRGBQUAD(RGB(0, 0, 0)), _T("Arial"), 40 - nRandomSize, 1000); //imgLetter.DrawTextA(NULL, nRandomOffset, 32, strLetter, imgLetter.RGBtoRGBQUAD(RGB(0, 0, 0)), "Arial", 40 - nRandomSize, 1000); float fRotate = (float)(35 - (GetRandomUInt16() % 70)); imgLetter.Rotate2(fRotate, NULL, CxImage::IM_BILINEAR, CxImage::OM_BACKGROUND, 0, false, true); uint32 nOffset = i * CROWDEDSIZE; ASSERT( imgLetter.GetHeight() == pimgResult->GetHeight() && pimgResult->GetWidth() >= nOffset + imgLetter.GetWidth() ); for (uint32 j = 0; j < imgLetter.GetHeight(); j++) for (uint32 k = 0; k < imgLetter.GetWidth(); k++) if (pimgResult->GetPixelIndex(nOffset + k, j) != 1) pimgResult->SetPixelIndex(nOffset + k, j, imgLetter.GetPixelIndex(k, j)); } pimgResult->Jitter(1); //pimgResult->Save("D:\\CaptchaTest.bmp", CXIMAGE_FORMAT_BMP); m_pimgCaptcha = pimgResult; }
void CClientMain::OnScreenShot() { CxImage ScreenImage = m_ScreenDisplayer.GetDisplayImage(); //if (ScreenImage.CreateFromHBITMAP(m_ScreenDisplayer.GetDisplayImage())) { ScreenImage.SetJpegQuality(m_dlgSetup.GetImageQuality()); TCHAR filter[] = _T("(*.bmp)|*.bmp |(*.gif)|*.gif|(*.jpg)|*.jpg|(*.png)|*.png|(*.tif)|*.tif|(*.tga)|*.tga|(*.pcx)|*.pcx|(*.wbmp)|*.wbmp|(*.wmf)|*.wmf|(*.jp2)|*.jp2|(*.jpc)|*.jpc|(*.pgx)|*.pgx|(*.raw)|*.raw||"); CFileDialog SaveDlg(false,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,filter); if (IDOK == SaveDlg.DoModal()) { CString FilePathName = SaveDlg.GetPathName(); std::map<int,const wchar_t* const> mapFileExt;//保存所要用到的文件后缀名 std::map<int,DWORD> mapSaveType;//保存所要的图片保存类型对应的CxImage宏 mapFileExt.insert(std::make_pair(1,_T(".bmp"))); mapFileExt.insert(std::make_pair(2,_T(".gif"))); mapFileExt.insert(std::make_pair(3,_T(".jpg"))); mapFileExt.insert(std::make_pair(4,_T(".png"))); mapFileExt.insert(std::make_pair(5,_T(".tif"))); mapFileExt.insert(std::make_pair(6,_T(".tga"))); mapFileExt.insert(std::make_pair(7,_T(".pcx"))); mapFileExt.insert(std::make_pair(8,_T(".wbmp"))); mapFileExt.insert(std::make_pair(9,_T(".wmf"))); mapFileExt.insert(std::make_pair(10,_T(".jp2"))); mapFileExt.insert(std::make_pair(11,_T(".jpc"))); mapFileExt.insert(std::make_pair(12,_T(".pgx"))); mapFileExt.insert(std::make_pair(13,_T(".raw"))); mapSaveType.insert(std::make_pair(1,CXIMAGE_FORMAT_BMP)); mapSaveType.insert(std::make_pair(2,CXIMAGE_FORMAT_GIF)); mapSaveType.insert(std::make_pair(3,CXIMAGE_FORMAT_JPG)); mapSaveType.insert(std::make_pair(4,CXIMAGE_FORMAT_PNG)); mapSaveType.insert(std::make_pair(5,CXIMAGE_FORMAT_TIF)); mapSaveType.insert(std::make_pair(6,CXIMAGE_FORMAT_TGA)); mapSaveType.insert(std::make_pair(7,CXIMAGE_FORMAT_PCX)); mapSaveType.insert(std::make_pair(8,CXIMAGE_FORMAT_WBMP)); mapSaveType.insert(std::make_pair(9,CXIMAGE_FORMAT_WMF)); mapSaveType.insert(std::make_pair(10,CXIMAGE_FORMAT_JP2)); mapSaveType.insert(std::make_pair(11,CXIMAGE_FORMAT_JPC)); mapSaveType.insert(std::make_pair(12,CXIMAGE_FORMAT_PGX)); mapSaveType.insert(std::make_pair(13,CXIMAGE_FORMAT_RAW)); int nFileExt = SaveDlg.m_ofn.nFilterIndex; const wchar_t *const tFileExt = mapFileExt[nFileExt]; DWORD dwSaveType = mapSaveType[nFileExt]; if(FilePathName.Right(4) !=tFileExt) { FilePathName += tFileExt; ScreenImage.Save(FilePathName.GetString() ,dwSaveType); } } } }
bool IGFrame::PickColor (POINT ptCoords, RGBQUAD& rgbColor) { // Request thread access if (!RequestAccess ()) return false; CxImage *pCurrentLayer = GetWorkingLayer(); if (!pCurrentLayer) return false; // convert IG coordinates to Cx coordinates IGConvertible::FromIGtoCxCoords (ptCoords, pCurrentLayer->GetHeight()); rgbColor = pCurrentLayer->GetPixelColor (ptCoords.x, ptCoords.y); return true; }
int IGIPFilter::GetSecondParam (IGImageProcMessage& message, CxImage& image) const { IGIPFilterMessage *pIGThreadMessage = dynamic_cast <IGLibrary::IGIPFilterMessage *> (&message); if (!pIGThreadMessage) return false; ZeroMemory (&pIGThreadMessage->m_rcSubLayer, sizeof (RECT)); if (image.GetWorkingLayer()) image.GetWorkingLayer()->SelectionGetBox (pIGThreadMessage->m_rcSubLayer); if ((pIGThreadMessage->m_rcSubLayer.right == 0) || (pIGThreadMessage->m_rcSubLayer.bottom == 0)) { pIGThreadMessage->m_rcSubLayer.right = -1; pIGThreadMessage->m_rcSubLayer.bottom = -1; } return (int)&pIGThreadMessage->m_rcSubLayer; }
virtual void LoadGifImage() { CDuiString sImag = m_pOwer->GetBkImage(); m_bLoadImg = true; m_pGifImage = CRenderEngine::LoadGifImageX(STRINGorID(sImag),0, 0); if ( NULL == m_pGifImage ) return; m_nFrameCount = m_pGifImage->GetNumFrames(); m_nFramePosition = 0; m_nDelay = m_pGifImage->GetFrameDelay(); if (m_nDelay <= 0 ) m_nDelay = 100; if(!m_bAutoStart) m_bRealStop = true; if(m_bAutoStart && m_pOwer->IsVisible()) StartAnim(); }
bool IGIPIndex::OnImageProcessing (CxImage& image, IGImageProcMessage& message) { IGIPIndexMessage *pIGThreadMessage = dynamic_cast <IGIPIndexMessage *> (&message); _ASSERTE (pIGThreadMessage && L"Wrong IGThread message, image processing aborted"); if (!pIGThreadMessage || !m_pFrame) return false; IGLayer *pLayer = m_pFrame->GetLayer (m_pFrame->GetLayerPos (image.GetWorkingLayer())); if (!pLayer) return false; switch (pIGThreadMessage->m_eFilterType) { case IGIPINDEX_LPE: { int nNbMarkers = 0; if (pIGThreadMessage->m_pMarkerBackground && pIGThreadMessage->m_pMarkerObject) { IGMarker* tM [2]; tM[0] = pIGThreadMessage->m_pMarkerBackground; tM[1] = pIGThreadMessage->m_pMarkerObject; nNbMarkers = 2; return pLayer->IndexLPE (tM, nNbMarkers); } else return pLayer->IndexLPE (NULL, nNbMarkers); } case IGIPINDEX_FACE: return pLayer->IndexFaces(); case IGIPINDEX_IRIS: return pLayer->IndexIris(); } return false; }
void CxImage::CreateFromHICON(HICON hico) { Destroy(); if (hico) { ICONINFO iinfo; GetIconInfo(hico,&iinfo); CreateFromHBITMAP(iinfo.hbmColor); #if CXIMAGE_SUPPORT_ALPHA CxImage mask; mask.CreateFromHBITMAP(iinfo.hbmMask); mask.GrayScale(); mask.Negative(); AlphaSet(mask); #endif } }
/** * Creates the selection channel from a gray scale image. * black = unselected */ bool CxImage::SelectionSet(CxImage &from) { if (!from.IsGrayScale() || head.biWidth != from.head.biWidth || head.biHeight != from.head.biHeight){ strcpy(info.szLastError,"CxImage::SelectionSet: wrong width or height, or image is not gray scale"); return false; } if (pSelection==NULL) pSelection = (uint8_t*)malloc(head.biWidth * head.biHeight); uint8_t* src = from.info.pImage; uint8_t* dst = pSelection; if (src==NULL || dst==NULL){ strcpy(info.szLastError,"CxImage::SelectionSet: null pointer"); return false; } for (int32_t y=0; y<head.biHeight; y++){ memcpy(dst,src,head.biWidth); dst += head.biWidth; src += from.info.dwEffWidth; } SelectionRebuildBox(); return true; }
void CMainFrame::SetImage(HANDLE hBitmap,TW_IMAGEINFO& /*info*/) { //<<<TWAIN>>> CDemoDoc *NewDoc=(CDemoDoc*)((CDemoApp*)AfxGetApp())->demoTemplate->OpenDocumentFile(NULL); if (NewDoc) { if (hBitmap){ CxImage *newima = new CxImage(); newima->CreateFromHANDLE(hBitmap); NewDoc->image = newima; } CString s; s.Format(_T("Acquired Image %d"),((CDemoApp*)AfxGetApp())->m_nDocCount++); NewDoc->SetTitle(s); NewDoc->UpdateAllViews(0,WM_USER_NEWIMAGE); NewDoc->UpdateStatusBar(); } }
void CToolBarCtrlZ::AddImageIcon(LPCTSTR lpszResource) { CxImage *pImage = new CxImage; pImage->LoadResource(FindResource(NULL, lpszResource, _T("PNG")), CXIMAGE_FORMAT_PNG); m_arrImgs.Add(pImage); // 同时增加ImageList,否则在SetButtonInfo时,大于button数的Image会被忽略。 <begin> CImageList *pil = GetImageList(); if (NULL == pil) { m_ilFake.Create(16, 16, ILC_COLOR, 5, 1); SetImageList(&m_ilFake); } if (NULL != pil) pil->Add(CTempIconLoader(_T("EMPTY"))); // 同时增加ImageList,否则在SetButtonInfo时,大于button数的Image会被忽略。 <end> }
/*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ bool CapturedImage::Get(CxImage& image) { bool ret = false; if (_bitmap_handle) ret = image.CreateFromHBITMAP(_bitmap_handle); return ret; }
BOOL CResponseParser::SaveAsImage( const wchar_t* lpszPath,const char* lpszContentData, uint32 dwContentSize, DWORD dwType) { CxImage image; bool bRet = false; DWORD dwFileType = CResponseParser::CheckImageFileHeader( (BYTE*)lpszContentData, dwContentSize); if( dwFileType == CXIMAGE_FORMAT_BMP ) { bRet = image.Decode( (BYTE*)lpszContentData, dwContentSize, CXIMAGE_FORMAT_BMP); } else if( dwFileType == CXIMAGE_FORMAT_GIF) { bRet = image.Decode( (BYTE*)lpszContentData, dwContentSize, CXIMAGE_FORMAT_GIF); } else if( dwFileType == CXIMAGE_FORMAT_JPG ) { bRet = image.Decode( (BYTE*)lpszContentData, dwContentSize, CXIMAGE_FORMAT_JPG); } else if( dwFileType == CXIMAGE_FORMAT_PNG) { bRet = image.Decode( (BYTE*)lpszContentData, dwContentSize, CXIMAGE_FORMAT_PNG); } if( bRet == true) { if( dwType == CXIMAGE_FORMAT_BMP) { return image.SaveW( lpszPath, CXIMAGE_FORMAT_BMP); } else if( dwType == CXIMAGE_FORMAT_GIF) { return image.SaveW( lpszPath, CXIMAGE_FORMAT_GIF); } else if( dwType == CXIMAGE_FORMAT_JPG) { return image.SaveW( lpszPath, CXIMAGE_FORMAT_JPG); } else if( dwType == CXIMAGE_FORMAT_PNG) { return image.SaveW( lpszPath, CXIMAGE_FORMAT_PNG); } else return image.SaveW( lpszPath, CXIMAGE_FORMAT_BMP); } return FALSE; }