本文整理汇总了C++中CImage::GetNumColors方法的典型用法代码示例。如果您正苦于以下问题:C++ CImage::GetNumColors方法的具体用法?C++ CImage::GetNumColors怎么用?C++ CImage::GetNumColors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CImage
的用法示例。
在下文中一共展示了CImage::GetNumColors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnDraw
/*
OnDraw()
*/
void CWallBrowserStretchView::OnDraw(CDC* pDC)
{
// documento
CWallBrowserDoc* pDoc = (CWallBrowserDoc*)GetDocument();
if(!pDoc)
return;
// nome file
memset(m_szFileName,'\0',sizeof(m_szFileName));
strcpyn(m_szFileName,pDoc->GetFileName(),sizeof(m_szFileName));
if(m_szFileName[0]=='\0')
return;
// immagine
CImage *pImage = pDoc->GetImage();
if(pImage && pImage->GetWidth() > 0 && pImage->GetHeight() > 0)
m_ImageDraw.SetImage(pImage);
else
return;
// immagine valida
if(!pDoc->GetPictureFlag())
return;
// dimensione corrente della vista
GetClientRect(&m_rcClient);
// adatta l'immagine alla dimensione corrente della vista
double nRemains = 0.0;
double nWidth = (double)pImage->GetWidth();
double nHeight = (double)pImage->GetHeight();
if(nHeight > (double)m_rcClient.bottom)
{
nRemains = FDIV(nHeight,(double)m_rcClient.bottom);
if(nRemains > 0.0)
{
nHeight = FDIV(nHeight,nRemains);
nWidth = FDIV(nWidth,nRemains);
}
}
if(nWidth > (double)m_rcClient.right)
{
nRemains = FDIV(nWidth,(double)m_rcClient.right);
if(nRemains > 0.0)
{
nHeight = FDIV(nHeight,nRemains);
nWidth = FDIV(nWidth,nRemains);
}
}
m_rcInvalid.SetRect(0,0,(int)nWidth,(int)nHeight);
// nome del file
if(m_pMainFrameStatusBar)
{
strcpyn(m_szStatus,pDoc->GetFileName(),sizeof(m_szStatus));
m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_FILENAME_ID,m_szStatus);
}
double nFactor = 0.0;
char szFactor[8] = {0};
if(m_nViewType==VIEWTYPE_SCROLL)
{
nFactor = GetZoomRatio();
if(nFactor >= 1.0)
sprintf(szFactor,"%.2f:1",nFactor);
else
sprintf(szFactor,"1:%.2f",1/nFactor);
}
// fattore di zoom e % di visualizzazione dell'immagine nella vista
int nRatio = (int)((nWidth * 100.0)/pImage->GetWidth());
if(m_pMainFrameStatusBar)
{
m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_ZOOM_ID,szFactor);
if(m_nViewType==VIEWTYPE_STRETCH)
_snprintf(m_szStatus,sizeof(m_szStatus)-1,"%d%% (stretch)",nRatio);
else
_snprintf(m_szStatus,sizeof(m_szStatus)-1,"%.1f%% (scroll)",nFactor * 100.0);
m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_RATIO_ID,m_szStatus);
}
// area della vista (client rect)
m_rcClient.right = (int)nWidth;
m_rcClient.bottom = (int)nHeight;
// ricava le informazioni per il titolo
char szTitle[_MAX_PATH+1] = {0};
int nColors = pImage->GetNumColors();
if(m_nViewType==VIEWTYPE_STRETCH)
_snprintf(szFactor,sizeof(szFactor)-1,"%d%%",nRatio);
_snprintf(szTitle,
sizeof(szTitle)-1,
"%s (%s) - %d x %d x %d%s",
//.........这里部分代码省略.........