本文整理汇总了C++中CxImage类的典型用法代码示例。如果您正苦于以下问题:C++ CxImage类的具体用法?C++ CxImage怎么用?C++ CxImage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CxImage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sprintf
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;
}
示例2: GetWorkingLayer
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;
}
示例3: GetSecondParam
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;
}
示例4: SetImageRectSelection
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;
}
示例5: UpdatePreview
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);
}
}
示例6: snapshotScreen
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;
}
示例7: SetImageRectSelection
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;
}
示例8: Cut
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;
}
示例9: GetFirstParam
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());
}
示例10: BitBlt
//鼠标在窗口上移动时需要进行的更新
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);
}
示例11: __declspec
__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);
};
示例12: ResampleKeepAspectArea
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);
}
示例13: CxImage
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;
}
示例14: loadImage
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;
}
示例15: GetLayer
CxImage* IGFrame::GetSelectionLayer()
{
for (int nIdxItem = 0; nIdxItem < GetNbLayers(); nIdxItem++)
{
CxImage *pLayer = GetLayer(nIdxItem);
if (pLayer->SelectionIsValid())
return pLayer;
}
return NULL;
}