本文整理汇总了C++中CImage::GetHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ CImage::GetHeight方法的具体用法?C++ CImage::GetHeight怎么用?C++ CImage::GetHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CImage
的用法示例。
在下文中一共展示了CImage::GetHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NotifyRanges
/*
NotifyRanges()
Posiziona l'immagine nella vista.
*/
void CWallBrowserStretchView::NotifyRanges(BOOL bResetZoom/*=TRUE*/)
{
CImage *pImage = GetDocument()->GetImage();
if(pImage)
{
CSize size(0,0);
if(bResetZoom)
{
size.cx = pImage->GetWidth();
size.cy = pImage->GetHeight();
}
else
{
size.cx = (int)((double)pImage->GetWidth() * GetZoomRatio());
size.cy = (int)((double)pImage->GetHeight() * GetZoomRatio());
}
SetZoomSizes(size);
if(bResetZoom)
{
SetZoomMode(MODE_ZOOMOFF);
SetZoomRatio(1.0);
}
}
}
示例2: ShapeWindowFromBitmap
void ShapeWindowFromBitmap(CImage &image,CWnd *pWnd,COLORREF keyColor)
{
pWnd->MoveWindow(0,0,image.GetWidth(),image.GetHeight());
if (!image.IsNull())
{
CRgn crRgn, crRgnTmp;
crRgn.CreateRectRgn(0,0,0,0);
for (int nY = 0; nY <= image.GetHeight(); nY++)
{
int nX = 0;
do
{
while (nX <= image.GetWidth() && image.GetPixel(nX, nY) == keyColor)
nX++;
int iLeftX = nX;
while (nX <= image.GetWidth() && image.GetPixel(nX, nY) != keyColor)
++nX;
crRgnTmp.CreateRectRgn(iLeftX, nY, nX, nY+1);
crRgn.CombineRgn(&crRgn, &crRgnTmp, RGN_OR);
crRgnTmp.DeleteObject();
}while(nX < image.GetWidth());
nX = 0;
}
pWnd->SetWindowRgn(crRgn,TRUE);
crRgn.DeleteObject();
}
}
示例3: 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;
}
示例4: CImageToMat
static BOOL CImageToMat(const CImage& image, Mat& img)
{
img.create(image.GetHeight(), image.GetWidth(), CV_8UC3);
if (img.data == NULL)
return FALSE;
// 支持24位、32位图
int bpp = image.GetBPP() / 8;
if (bpp < 3)
return FALSE;
for (int y = 0; y < image.GetHeight(); y++)
{
BYTE* src = (BYTE*)image.GetPixelAddress(0, y);
BYTE* dst = img.ptr<BYTE>(y);
for (int x = 0; x < image.GetWidth(); x++)
{
dst[0] = src[0];
dst[1] = src[1];
dst[2] = src[2];
src += bpp;
dst += 3;
}
}
return TRUE;
}
示例5: 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;
}
示例6: GetImageSize
// 取图片显示的尺寸
SIZE CImageViewDlg::GetImageSize(const CImage& image)
{
CRect rect;
m_imageStatic.GetWindowRect(rect);
if (image.GetWidth() <= rect.Width())
return SIZE{ image.GetWidth(), image.GetHeight() };
else
{
float scale = (float)rect.Width() / image.GetWidth();
return SIZE{ rect.Width(), (int)(image.GetHeight() * scale) };
}
}
示例7: WriteImage
//
// WriteImage()
// write an image to a file in PNG format
// This version writes the entire image
//
void CImageIOPng::WriteImage(const CImage& image, CNcbiOstream& ostr,
CImageIO::ECompress compress)
{
// make sure we've got an image
if ( !image.GetData() ) {
NCBI_THROW(CImageException, eWriteError,
"CImageIOPng::WriteImage(): "
"attempt to write an empty image");
}
// validate our image - we need RGB or RGBA images
if (image.GetDepth() != 3 && image.GetDepth() != 4) {
string msg("CImageIOPng::WriteImage(): invalid image depth: ");
msg += NStr::NumericToString(image.GetDepth());
NCBI_THROW(CImageException, eWriteError, msg);
}
png_structp png_ptr = NULL;
png_infop info_ptr = NULL;
try {
// initialize png stuff
s_PngWriteInit(png_ptr, info_ptr,
image.GetWidth(), image.GetHeight(), image.GetDepth(),
compress);
// begin writing data
png_set_write_fn(png_ptr, &ostr, s_PngWrite, s_PngFlush);
png_write_info(png_ptr, info_ptr);
// write our image, line-by-line
unsigned char* row_ptr = const_cast<unsigned char*> (image.GetData());
size_t width = image.GetWidth();
size_t height = image.GetHeight();
size_t depth = image.GetDepth();
for (size_t i = 0; i < height; ++i) {
png_write_row(png_ptr, row_ptr);
row_ptr += width * depth;
}
// standard clean-up
png_write_end(png_ptr, info_ptr);
s_PngWriteFinalize(png_ptr, info_ptr);
}
catch (...) {
s_PngWriteFinalize(png_ptr, info_ptr);
throw;
}
}
示例8: OnEditCopy
/*
OnEditCopy()
*/
void CWallBrowserStretchView::OnEditCopy(void)
{
CWaitCursor cursor;
BOOL bCopied = FALSE;
// copia il contenuto dell'immagine nella clipboard
if(::OpenClipboard(NULL))
{
if(::EmptyClipboard())
{
CWallBrowserDoc* pDoc = (CWallBrowserDoc*)GetDocument();
if(pDoc)
{
CImage *pImage = pDoc->GetImage();
if(pImage && pImage->GetWidth() > 0 && pImage->GetHeight() > 0)
bCopied = ::SetClipboardData(CF_DIB,pImage->GetDIB())!=(HANDLE)NULL;
}
}
::CloseClipboard();
}
// imposta il redo con l'ultima operazione effettuata
if(bCopied)
RedoPush(ID_EDIT_COPY);
}
示例9: copyImgDataToCImage
bool copyImgDataToCImage(CImage &srcImage,CImage &dstImage,int margin)
{
margin = abs(margin);
//读取图像宽高
int width = srcImage.GetWidth();
int height = srcImage.GetHeight();
if(margin*2 > width)
{
return false;
}
//new width
int imgWidth = width-2*margin;
if(!dstImage.CreateEx(imgWidth,height, 24, BI_RGB))//创建CImage 对象
{
return false;
}
//设置像素
for(int i = height - 1;i >= 0 ; i--)
{
for(int j = 0; j < imgWidth;j++)
{
BYTE *pDst = (BYTE*)dstImage.GetPixelAddress(j, i);
BYTE *pSrc = (BYTE*)srcImage.GetPixelAddress(j + margin, i);
//读取并设置 rgb值
*pDst++ = *pSrc++; // b分量值
*pDst++ = *pSrc++; //g 分量
*pDst = *pSrc; // r分量
}
//new offset
}
return true;
}
示例10: ShowPhoto
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;
}
示例11: OnEraseBackground
LRESULT CAboutDlg::OnEraseBackground(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
/*
HBITMAP hPicture = LoadBitmap(_Module.GetModuleInstance(), MAKEINTRESOURCE(IDB_LOGO));
BITMAP bm;
GetObject(hPicture, sizeof (BITMAP), (LPSTR)&bm);
CMemDC memdc((HDC)wParam, NULL);
HDC hdcCompatible = CreateCompatibleDC(memdc);
HBITMAP hOldBMP = (HBITMAP)SelectObject(hdcCompatible, hPicture);
RECT rcClient;
GetClientRect(&rcClient);
memdc.FillSolidRect(&rcClient, GetSysColor(COLOR_3DFACE));
memdc.TransparentBlt(107-bm.bmWidth/2, 116-bm.bmHeight/2, bm.bmWidth, bm.bmHeight, hdcCompatible,
0, 0, bm.bmWidth, bm.bmHeight, 0xff00ff);
SelectObject(hdcCompatible, hOldBMP);
DeleteDC(hdcCompatible);
DeleteObject(hPicture);
/*/
CImage Image;
LoadImage(&Image, _Module.GetModuleInstance(), IDB_LOGO);
CMemDC memdc((HDC)wParam, NULL);
RECT rcClient;
GetClientRect(&rcClient);
memdc.FillRect(&rcClient, COLOR_3DFACE);
Image.AlphaBlend(memdc, 107-Image.GetWidth()/2, 116-Image.GetHeight()/2, Image.GetWidth(), Image.GetHeight(), 0, 0, Image.GetWidth(), Image.GetHeight());
/**/
return 0;
}
示例12: CodeToFile
void CDevILCodec::CodeToFile(const nstring & filename, const CImage &image)
{
ILuint imageid;
CDevILFormats informat;
informat.SetExFormat(image.GetPixelFormat());
// Generate the main image name to use.
ilGenImages(1, &imageid);
// Bind this image name.
ilBindImage(imageid);
ilTexImage(image.GetWidth(), image.GetHeight(), image.GetDepth(), informat.GetInternalChannels(),
informat.GetFormat(), IL_UNSIGNED_BYTE, image.GetBitsPtr());
ilSaveImage(filename.c_str());
ilDeleteImages(1, &imageid);
ILenum Error = 0;
if((Error = ilGetError()) != NULL)
{
nstring str("CDevILCodec::CodeToFile: ");
str.append(iluErrorString(Error));
throw NOVA_EXP(str.c_str(), BAD_OPERATION);
}
}
示例13: initMapDetail
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();
}
示例14: getRectImage_width
void PDFwin::getRectImage_width(int pageNo, int rectNo, int width, CImage& image)
{
SelectionRectangle& rect=::find(mRects, rectNo);
PDFDoc* _pdfDoc=mModel->_pdfDoc ;
SplashOutputDev* _outputDev=mModel->_outputDev;
int totalWidth=int((double)width/(rect.p2.x-rect.p1.x)+0.5);
FlLayout* layout=mLayout->findLayout("Automatic segmentation");
int maxWidth=int((double)width/(1.0/(layout->findSlider("N columns")->value()+1.0))+0.5);
totalWidth=MIN(maxWidth, totalWidth);
double DPI = mModel->calcDPI_width(totalWidth, pageNo);
int totalHeight=mModel->calcHeight_DPI(DPI, pageNo);
int left=int(rect.p1.x*(double)totalWidth+0.5);
int top=int(rect.p1.y*(double)totalHeight+0.5);
int right=int(rect.p2.x*(double)totalWidth+0.5);
int bottom=int(rect.p2.y*(double)totalHeight+0.5);
_pdfDoc->displayPageSlice(_outputDev, pageNo+1, DPI, DPI, 0, gFalse, gTrue, gFalse, left,top, right-left,bottom-top);
SplashBitmap* bmp=_outputDev->takeBitmap();
image.SetData(bmp->getWidth(), bmp->getHeight(), bmp->getDataPtr(), bmp->getRowSize());
//ASSERT(image.GetWidth()==width || totalWidth==maxWidth);
ASSERT(image.GetHeight()==bottom-top);
delete bmp;
}
示例15: getRectImage_height
void PDFwin::getRectImage_height(int pageNo, int rectNo, int height, CImage& image)
{
SelectionRectangle& rect=::find(mRects, rectNo);
int totalHeight=int((double)height/(rect.p2.y-rect.p1.y)+0.5);
double DPI=getDPI_height(pageNo, rectNo, height);
PDFDoc* _pdfDoc=mModel->_pdfDoc ;
SplashOutputDev* _outputDev=mModel->_outputDev;
int totalWidth=mModel->calcWidth_DPI(DPI, pageNo);
int left=int(rect.p1.x*(double)totalWidth+0.5);
int top=int(rect.p1.y*(double)totalHeight+0.5);
int bottom=int(rect.p2.y*(double)totalHeight+0.5);
int right=int(rect.p2.x*(double)totalWidth+0.5);
_pdfDoc->displayPageSlice(_outputDev, pageNo+1, DPI, DPI, 0, gFalse, gTrue, gFalse, left,top, right-left,height);
SplashBitmap* bmp=_outputDev->takeBitmap();
image.SetData(bmp->getWidth(), bmp->getHeight(), bmp->getDataPtr(), bmp->getRowSize());
ASSERT(image.GetWidth()==right-left);
ASSERT(image.GetHeight()==height);
delete bmp;
}