本文整理汇总了C++中CDib类的典型用法代码示例。如果您正苦于以下问题:C++ CDib类的具体用法?C++ CDib怎么用?C++ CDib使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CDib类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetEvent
void CVisionTab::updateDepthStream()
{
if(WAIT_OBJECT_0 == WaitForSingleObject(kinect.m_dFrameReadyEvent, 0))
{
if(pBufDepth == NULL && pDepth != NULL) {
pBufDepth = pDepth->CopyCDib();
SetEvent(m_GetDimgEvent);
}
if(pDepth != NULL) {delete pDepth; pDepth=NULL;}
CDib *pDibDepth = kinect.getCDibDepthImage()->CopyCDib();
pDepth = pDibDepth->CopyCDib();
if(pDibDepth) {
// Display update
if(clip) {
CDib *pDepth = pDibDepth->ClipCDib(m_ClipRect); // memory leak when using median filter...
m_DispDepth.SetDib(pDepth);
} else {
m_DispDepth.SetDib(pDibDepth->CopyCDib());
}
delete pDibDepth;
}
}
}
示例2: Copy
void CDib::Copy(const CDib& dib, UINT nBitCount)
{
if( &dib != this)
{
Empty();
if( !dib.IsNull() )
{
int height = dib.GetHeight();
int width = dib.GetWidth();
Create(width, height, nBitCount);
if( nBitCount <= 8)
{
CPalette palette;
dib.CreatePaletteFromImage(palette);
SetPalette( palette );
//MakePalette();
}
for(int i=0; i<width; i++)
{
for(int j=0; j<height; j++)
{
SetPixel(i,j, dib.GetPixel(i, j) );
}
}
}
}
}
示例3: CDib
/*
*--------------------------------------------------------------------------------
* 函数名 : MergeDib
* 功能 : 将窗口内的图像与指定图像融合
* 参数 : CDib* pDib - 画布图像,融合于此DIB之上
* 算法 : 先隐藏按钮,然后将窗口内的图像抓取下来,再将此DIB与参数DIB融合
*--------------------------------------------------------------------------------
*/
BOOL CFloatDibWnd::MergeDib(CDib * pDib)
{
CDib* newDib = new CDib();
// 隐藏全部形变按钮
if(g_createBtn)
HideAllButton();
CRect rcSelf, rcParent;
GetWindowRect(&rcSelf);
::GetWindowRect(m_hParentWnd, &rcParent);
// 抓取浮动窗口客户区图像
newDib->Create(GetSafeHwnd(), CRect(0, 0, rcSelf.Width(), rcSelf.Height()) );
// 计算起点座标
int xStart, yStart;
// 减 2 是因为边框占两个像素
xStart = rcSelf.left - rcParent.left - 2;
yStart = rcSelf.top - rcParent.top - 2;
pDib->MergeDib(newDib->GetHandle(), CPoint(xStart, yStart));
delete newDib;
return TRUE;
}
示例4: CDib
BOOL CSpermView::WriteImageToDisk(int i, CFile *pFile)
{
CDib *pDib = new CDib(m_lpBMIH[i], m_lpImage[i]);
BOOL ret = pDib->SaveDibFile(pFile);
delete pDib, pDib = NULL;
return ret;
}
示例5: ASSERT
ERMsg CDib::SaveImage(const CString& filePath, REFGUID guidFileType, int bpp)const
{
ASSERT( guidFileType != GUID_NULL || !UtilWin::GetFileExtension(filePath).IsEmpty() );
ERMsg message;
if( bpp == -1)
{
bpp = GetBPP();
}
else if( bpp != GetBPP())
{
CDib dib;
dib.Copy( *this, bpp);
return dib.SaveImage(filePath, guidFileType);
}
if( FAILED(Save(filePath, guidFileType)))
{
CString error;
error.FormatMessage(IDS_BSC_UNABLE_OPEN_WRITE, filePath );
message.ajoute( UtilWin::ToUTF8(error) );
}
return message;
}
示例6: CopyRect
VOID CDibUtil::CopyRect(CDib& src, CDib& dest, const CRect rect)
{
// TODO: The validation of rect in source and destination
// images should be checked
for (LONG y = rect.top; y <= rect.bottom; ++y)
for (LONG x = rect.left; x <= rect.right; ++x)
dest.WritePixel(x, y, src.GetPixel(x, y));
}
示例7: Subtract
VOID CDibUtil::Subtract(CDib& imgA, CDib& imgB, CDib& dest)
{
dest.CopyDib(&imgA);
CSize imageSize = imgA.GetDimensions();
for (LONG y = 0; y != imageSize.cy; ++y)
for (LONG x = 0; x != imageSize.cx; ++x)
{
dest.WritePixel(x, y, RGBSUB(imgA.GetPixel(x, y), imgB.GetPixel(x, y)));
}
}
示例8: GetDepthImage
CDib* CVisionTab::GetDepthClipImage(RECT *pRect)
{
CDib* pTmp;
CDib* pDib;
if(WAIT_OBJECT_0 == WaitForSingleObject(m_GetDimgEvent, INFINITE))
pTmp = GetDepthImage();
if(pTmp) pDib = pTmp->ClipCDib(pRect);
delete pTmp; pTmp=NULL;
return pDib;
}
示例9: AfxThrowResourceException
BOOL CGelDoc::LoadSample(LPCTSTR pszFilename)
{
CFile file;
CDib* pDib = NULL;
TRY
{
if (!file.Open(pszFilename, CFile::modeRead | CFile::shareDenyNone))
AfxThrowResourceException();
pDib = new CDib();
pDib->LoadDib(&file); // throws
pDib->DeleteDib();
delete pDib;
pDib = NULL;
// If we got this far, go for the gusto and replace our sample.
delete m_pUntransformed;
file.Seek(0L, CFile::begin);
m_pUntransformed = new CDib(&file);
delete m_pTransformed;
file.Seek(0L, CFile::begin);
m_pTransformed = new CDib(&file);
delete m_pSelection;
file.Seek(0L, CFile::begin);
m_pSelection = new CDib(&file);
file.Close();
}
CATCH_ALL(e)
{
if (pDib)
delete pDib;
if (file.m_hFile)
file.Close();
return FALSE;
}
END_CATCH_ALL
ApplyGel();
ApplySelection();
CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
if (pFrame)
pFrame->UpdateSample();
return TRUE;
}
示例10: ASSERT
/*
*--------------------------------------------------------------------------------
* 成员函数名 : OnPaint()
* 功能描述 : 绘制窗体或窗体尺寸发生改变时重画窗体
* 算法 : 透明显示位图,透明色为 g_stuPaintSet.tranCol
* 附加说明 : 窗口缩放时图像并不改变,而是在显示时改变复制位图,然后缩放显示
*--------------------------------------------------------------------------------
*/
void CFloatDibWnd::OnPaint()
{
ASSERT(m_pDib);
CRect rect;
GetClientRect(&rect);
// 用当前图像创建一个临时位图,对它进行缩放显示,以防失真
CDib *pTmpDib = m_pDib->Clone();
pTmpDib->ChangeImageSize(rect.Width(), rect.Height());
pTmpDib->DisplayTransparent(GetDC(), 0, 0, g_stuPaintSet.tranCol);
delete pTmpDib;
CWnd::OnPaint();
}
示例11: GetBitmapDC
BOOL CDib::GetBitmapDC(LPCSTR filename,HDC screenDC,HDC& hdc)
{
CDib dib;
LPCDibinfo bit;
bit = dib.GetBitmap(filename);
hdc = CreateCompatibleDC(screenDC);
HBITMAP bitmap = CreateCompatibleBitmap(screenDC,bit->DI_Width,bit->DI_Height);
SelectObject(hdc,bitmap);
SetDIBitsToDevice(hdc,0,0,bit->DI_Width,bit->DI_Height,0,0,0,bit->DI_Height,bit->DI_Bitmap,bit->DI_BitmapInfo,DIB_RGB_COLORS);
DeleteObject(bitmap);
bit->DI_Release();
return TRUE;
}
示例12: Graying
VOID CDibUtil::Graying(CDib& src, CDib& dest)
{
dest.CopyDib(&src);
CSize imageSize = src.GetDimensions();
RGBQUAD color;
for (LONG y = 0; y != imageSize.cy; ++y)
for (LONG x = 0; x != imageSize.cx; ++x)
{
color = src.GetPixel(x, y);
color.rgbRed = color.rgbGreen = color.rgbBlue
= GRAYING(color.rgbRed, color.rgbGreen, color.rgbBlue);
dest.WritePixel(x, y, color);
}
}
示例13: Binaryzation
VOID CDibUtil::Binaryzation(CDib& src, CDib& dest, BYTE threshold)
{
dest.CopyDib(&src);
CSize imageSize = src.GetDimensions();
RGBQUAD color;
for (LONG y = 0; y != imageSize.cy; ++y)
for (LONG x = 0; x != imageSize.cx; ++x)
{
color = src.GetPixel(x, y);
color.rgbRed = color.rgbGreen = color.rgbBlue
= (GRAYING(color.rgbRed, color.rgbGreen, color.rgbBlue) < threshold) ? 0x00 : 0xFF;
dest.WritePixel(x, y, color);
}
}
示例14: while
void CDibMgr::RemoveAllDibs()
{
// Delete all dibs from our collection...
POSITION pos = m_collDibs.GetHeadPosition();
while (pos)
{
CDib* pDib = (CDib*)m_collDibs.GetNext(pos);
ASSERT(pDib && pDib->IsValid());
delete pDib;
}
m_collDibs.RemoveAll();
}
示例15: ASSERT
CDib* CDibMgr::AddDib(const char* sFile, DWORD flags)
{
// Sanity checks...
ASSERT(IsValid());
ASSERT(sFile);
// Get an hDC to our window...
HDC hDC = GetDC(FALSE);
// Set the global hInst in case we are trying to load a res...
s_hInst = m_hInst;
// Create and init a new dib...
CDib* pDib = new CDib();
if (!pDib->Init(sFile, hDC, flags))
{
ReleaseDC(hDC);
delete pDib;
return(NULL);
}
// Add the new dib to our collection...
POSITION pos = m_collDibs.AddTail(pDib);
pDib->SetPos(pos);
// Clean up...
ReleaseDC(hDC);
// All done...
return(pDib);
}