static SapData SetDataValue(SapBuffer pBuffers, UInt32 pPrmIndex) { if (IsMonoBuffer(pBuffers)) { SapDataMono mono = new SapDataMono(128); return(mono); } else { SapDataRGB rgb = new SapDataRGB(); //SapDataRGB rgb(m_pInfoList->GetValueAt(*pPrmIndex), m_pInfoList->GetValueAt(*pPrmIndex+1), m_pInfoList->GetValueAt(*pPrmIndex+2)); pPrmIndex = pPrmIndex + 3; return(rgb); } }
private String GetPixelString(Point point) { String str = "[ Pixel data not available ]"; // if there is no buffer to display, return right away if (m_pView == null || m_pView.Buffer == null || !m_pView.Buffer.Mapped) { return(str); } if (m_pView.Buffer != null) { Point pt = TranslatePos(point); // Get pixel value at cursor's position and create string according to pixel format String text = ""; SapFormat format = m_pView.Buffer.Format; switch (format) { case SapFormat.Uint8: case SapFormat.Int8: case SapFormat.Int16: case SapFormat.Uint16: case SapFormat.Int24: case SapFormat.Uint24: case SapFormat.Int32: case SapFormat.Uint32: case SapFormat.Int64: case SapFormat.Uint64: SapDataMono dataMono = new SapDataMono(); m_pView.Buffer.ReadElement(pt.X, pt.Y, dataMono); text = String.Format("[ x= {0} y= {1} Value= {2} ]", pt.X, pt.Y, dataMono.Mono); break; case SapFormat.LAB: case SapFormat.LAB101010: SapDataLAB dataLAB = new SapDataLAB(); m_pView.Buffer.ReadElement(pt.X, pt.Y, dataLAB); text = String.Format("[ x= {0} y= {1} L= (2) A= (3) B= (4) ]", pt.X, pt.Y, dataLAB.L, dataLAB.A, dataLAB.B); break; case SapFormat.LAB16161616: SapDataLABA dataLABA = new SapDataLABA(); m_pView.Buffer.ReadElement(pt.X, pt.Y, dataLABA); text = String.Format("[ x= {0} y= {1} L= (2) A= (3) B= (4) ]", pt.X, pt.Y, dataLABA.L, dataLABA.A, dataLABA.B); break; case SapFormat.HSI: case SapFormat.HSIP8: SapDataHSI dataHSI = new SapDataHSI(); m_pView.Buffer.ReadElement(pt.X, pt.Y, dataHSI); text = String.Format("[ x= {0} y= {1} H= {2} S= {3} I= {4} ]", pt.X, pt.Y, dataHSI.H, dataHSI.S, dataHSI.I); break; case SapFormat.HSV: SapDataHSV dataHSV = new SapDataHSV(); m_pView.Buffer.ReadElement(pt.X, pt.Y, dataHSV); text = String.Format("[x= {0} y= {1} H= {2} S= {3} V= {4}]", pt.X, pt.Y, dataHSV.H, dataHSV.S, dataHSV.V); break; case SapFormat.YUV: SapDataYUV dataYUV = new SapDataYUV(); m_pView.Buffer.ReadElement(pt.X, pt.Y, dataYUV); text = String.Format("[ x= {0} y= {1} Y= {2} U= {3} V= {4} ]", pt.X, pt.Y, dataYUV.Y, dataYUV.U, dataYUV.V); break; case SapFormat.RGB161616: case SapFormat.RGB101010: case SapFormat.RGB565: case SapFormat.RGB888: case SapFormat.RGBR888: case SapFormat.RGB8888: SapDataRGB dataRGB = new SapDataRGB(); m_pView.Buffer.ReadElement(pt.X, pt.Y, dataRGB); text = String.Format("[ x= {0} y= {1} R= {2} G= {3} B= {4} ]", pt.X, pt.Y, dataRGB.Red, dataRGB.Green, dataRGB.Blue); break; case SapFormat.RGB16161616: SapDataRGBA dataRGBA = new SapDataRGBA(); m_pView.Buffer.ReadElement(pt.X, pt.Y, dataRGBA); text = String.Format("[ x= {0} y= {1} R= {2} G= {3} B= {4} ]", pt.X, pt.Y, dataRGBA.Red, dataRGBA.Green, dataRGBA.Blue); break; case SapFormat.RGBP8: case SapFormat.RGBP16: case SapFormat.LABP8: case SapFormat.LABP16: dataRGB = new SapDataRGB(); m_pView.Buffer.ReadElement(pt.X, pt.Y, dataRGB); string formatStr; if (format == SapFormat.RGBP8 || format == SapFormat.LABP8) { formatStr = "[ x= %03ld y= %03ld Value= %03d ]"; } else { formatStr = "[ x= %03ld y= %03ld Value= %04X ]"; } int page = m_pView.Buffer.Page; if (page == 0) { text = String.Format(formatStr, pt.X, pt.Y, dataRGB.Red); } else if (page == 1) { text = String.Format(formatStr, pt.X, pt.Y, dataRGB.Green); } else if (page == 2) { text = String.Format(formatStr, pt.X, pt.Y, dataRGB.Blue); } break; default: break; } // Append string to application title str = " " + text; } return(str); }