CString CImageWnd::GetPixelString(CPoint point) { if (!m_pView || !*m_pView || m_pView->GetBuffer() == NULL || !*m_pView->GetBuffer() || !m_pView->GetBuffer()->IsMapped() || !IsPointInside(point)) return CImageWnd::GetPixelString(NULL, CPoint(0, 0)); CPoint pt = TranslateMousePos(point); return CImageWnd::GetPixelString(m_pView->GetBuffer(), pt, m_PixelStringFormatDecimal); }
CString CImageWnd::GetPixelString(CPoint point) { CString str = _T("[ Pixel data not available ]"); // if there is no buffer to display, return right away if (m_pView == NULL || !(*m_pView) || m_pView->GetBuffer() == NULL || !m_pView->GetBuffer()->IsMapped()) return str; if (IsPointInside(point) && *m_pView->GetBuffer()) { CPoint pt = TranslateMousePos(point); // Get pixel value at cursor's position and create string according to pixel format CString text; SapFormat format = m_pView->GetBuffer()->GetFormat(); if (format == SapFormatHSI || format == SapFormatHSIP8) { SapDataHSI data; m_pView->GetBuffer()->ReadElement(pt.x, pt.y, &data); text.Format(_T("[ x:%03ld y:%03ld H:0x%04x S:0x%04x I:0x%04x ]"), pt.x, pt.y, data.H(), data.S(), data.I()); } else if (format == SapFormatLAB || format == SapFormatLAB101010) { SapDataLAB data; m_pView->GetBuffer()->ReadElement(pt.x, pt.y, &data); text.Format(_T("[ x:%03ld y:%03ld L:0x%04x A:0x%04x B:0x%04x ]"), pt.x, pt.y, data.L(), data.A(), data.B()); } else if (format == SapFormatLAB16161616) { SapDataLABA data; m_pView->GetBuffer()->ReadElement(pt.x, pt.y, &data); text.Format(_T("[ x:%03ld y:%03ld L:0x%04x A:0x%04x B:0x%04x ]"), pt.x, pt.y, data.L(), data.A(), data.B()); } else if (format == SapFormatHSV) { SapDataHSV data; m_pView->GetBuffer()->ReadElement(pt.x, pt.y, &data); text.Format(_T("[ x:%03ld y:%03ld H:0x%04x S:0x%04x V:0x%04x ]"), pt.x, pt.y, data.H(), data.S(), data.V()); } else if (CORDATA_FORMAT_IS_YUV(format)) { SapDataYUV data; m_pView->GetBuffer()->ReadElement(pt.x, pt.y, &data); text.Format(_T("[ x:%03ld y:%03ld Y:0x%04x U:0x%04x V:0x%04x ]"), pt.x, pt.y, data.Y(), data.U(), data.V()); } else if (CORDATA_FORMAT_IS_RGB(format)) { if(format==SapFormatRGB16161616) { SapDataRGBA data; m_pView->GetBuffer()->ReadElement(pt.x, pt.y, &data); text.Format(_T("[ x:%03ld y:%03ld R:0x%04x G:0x%04x B:0x%04x ]"), pt.x, pt.y, data.Red(), data.Green(), data.Blue()); } else { SapDataRGB data; m_pView->GetBuffer()->ReadElement(pt.x, pt.y, &data); text.Format(_T("[ x:%03ld y:%03ld R:0x%04x G:0x%04x B:0x%04x ]"), pt.x, pt.y, data.Red(), data.Green(), data.Blue()); } } else if (format == SapFormatRGBP8 || format == SapFormatLABP8 || format == SapFormatRGBP16 || format == SapFormatLABP16) { SapData data; m_pView->GetBuffer()->ReadElement(pt.x, pt.y, &data); SapDataRGB dataRGB = data; TCHAR fmtStr8[] = _T("[ x:%03ld y:%03ld value:%03d ]"); TCHAR fmtStr16[] = _T("[ x:%03ld y:%03ld value:0x%04x ]"); TCHAR* pFmtStr; if (format == SapFormatRGBP8 || format == SapFormatLABP8) pFmtStr = fmtStr8; else pFmtStr = fmtStr16; int page; m_pView->GetBuffer()->GetParameter(CORBUFFER_PRM_PAGE,&page); if(page==0) text.Format(CString(pFmtStr), pt.x, pt.y, dataRGB.Red()); else if(page==1) text.Format(CString(pFmtStr), pt.x, pt.y, dataRGB.Green()); else if(page==2) text.Format(CString(pFmtStr), pt.x, pt.y, dataRGB.Blue()); } else { SapDataMono data; m_pView->GetBuffer()->ReadElement(pt.x, pt.y, &data); text.Format(_T("[ x:%03ld y:%03ld value:0x%04x ]"), pt.x, pt.y, data.Mono()); } // Append string to application title str = _T(" ") + CString(text); } return str; }