public RawFileDlg(int width, int height, int offset, SapFormat format) { InitializeComponent(); // Read file name string keyPath = "Software\\Teledyne DALSA\\" + Application.ProductName + "\\SapFile"; RegistryKey regkey = Registry.CurrentUser.OpenSubKey(keyPath); if (regkey != null) { textBox_Width.Text = regkey.GetValue("Raw Width", width).ToString(); textBox_Height.Text = regkey.GetValue("Raw Height", height).ToString(); textBox_Offset.Text = regkey.GetValue("Raw Offset", offset).ToString(); m_Format = (SapFormat)Enum.Parse(typeof(SapFormat), regkey.GetValue("Raw Format", format).ToString(), true); } for (int i = 0; i < m_FormatInfo.Length; i++) { comboBox_RawFormat.Items.Add(m_FormatInfo[i].ToString()); if ((m_FormatInfo[i].Value == m_Format) || ((m_Format == 0) && (m_FormatInfo[i].Value == SapFormat.Mono8))) { comboBox_RawFormat.SelectedIndex = i; } } if (m_Format != 0) { comboBox_RawFormat.Enabled = false; } }
static bool IsMonoBuffer(SapBuffer pBuffers) { SapFormat format = pBuffers.Format; if (format == SapFormat.Uint8 || format == SapFormat.Int8 || format == SapFormat.Int16 || format == SapFormat.Uint16 || format == SapFormat.Int24 || format == SapFormat.Uint24 || format == SapFormat.Int32 || format == SapFormat.Uint32 || format == SapFormat.Int64 || format == SapFormat.Uint64) { return(true); } else { return(false); } }
private bool AddRawOptions() { int width = (m_pBuffer != null) ? m_pBuffer.Width : RAW_DEFAULT_WIDTH; int height = (m_pBuffer != null) ? m_pBuffer.Height : RAW_DEFAULT_HEIGHT; SapFormat format = (m_pBuffer != null) ? m_pBuffer.Format : 0; RawFileDlg dlg = new RawFileDlg(width, height, RAW_DEFAULT_OFFSET, format); if (dlg.ShowDialog() != DialogResult.OK) { return(false); } string strQuality = " -width " + dlg.RawFileWidth.ToString() + " -height " + dlg.RawFileHeight.ToString() + " -offset " + dlg.RawFileOffset.ToString(); m_Options += strQuality; return(true); }
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); }
static void GetImageDepth(SapFormat format, out IplDepth depth, out int channels, out SapFormat outputFormat) { switch (format) { case SapFormat.Binary: case SapFormat.Mono8: channels = 1; depth = IplDepth.U8; outputFormat = SapFormat.Mono8; break; case SapFormat.RGB888: channels = 3; depth = IplDepth.U8; outputFormat = SapFormat.RGB888; break; case SapFormat.AYU2: case SapFormat.BICOLOR1616: case SapFormat.BICOLOR88: case SapFormat.ColorI10: case SapFormat.ColorI11: case SapFormat.ColorI12: case SapFormat.ColorI13: case SapFormat.ColorI14: case SapFormat.ColorI15: case SapFormat.ColorI16: case SapFormat.ColorI8: case SapFormat.ColorI9: case SapFormat.ColorNI10: case SapFormat.ColorNI11: case SapFormat.ColorNI12: case SapFormat.ColorNI13: case SapFormat.ColorNI14: case SapFormat.ColorNI15: case SapFormat.ColorNI16: case SapFormat.ColorNI8: case SapFormat.ColorNI9: case SapFormat.Complex: case SapFormat.FPoint: case SapFormat.Float: case SapFormat.HSI: case SapFormat.HSIP16: case SapFormat.HSIP8: case SapFormat.HSV: case SapFormat.HSVP16: case SapFormat.HSVP8: case SapFormat.IYU1: case SapFormat.IYU2: case SapFormat.Int10: case SapFormat.Int11: case SapFormat.Int12: case SapFormat.Int13: case SapFormat.Int14: case SapFormat.Int15: case SapFormat.Int16: case SapFormat.Int24: case SapFormat.Int32: case SapFormat.Int64: case SapFormat.Int8: case SapFormat.Int9: case SapFormat.LAB: case SapFormat.LAB101010: case SapFormat.LAB16161616: case SapFormat.Mono10: case SapFormat.Mono11: case SapFormat.Mono12: case SapFormat.Mono13: case SapFormat.Mono14: case SapFormat.Mono15: case SapFormat.Mono16: case SapFormat.Mono16P2: case SapFormat.Mono16P3: case SapFormat.Mono16P4: case SapFormat.Mono24: case SapFormat.Mono32: case SapFormat.Mono64: case SapFormat.Mono8P2: case SapFormat.Mono8P3: case SapFormat.Mono8P4: case SapFormat.Mono9: case SapFormat.Point: case SapFormat.RGB101010: case SapFormat.RGB161616: case SapFormat.RGB16161616: case SapFormat.RGB161616_MONO16: case SapFormat.RGB5551: case SapFormat.RGB565: case SapFormat.RGB8888: case SapFormat.RGB888_MONO8: case SapFormat.RGBP16: case SapFormat.RGBP8: case SapFormat.RGBR888: case SapFormat.UYVY: case SapFormat.Unknown: case SapFormat.Y211: case SapFormat.YUVP16: case SapFormat.YUVP8: case SapFormat.YUY2: case SapFormat.YUYV: case SapFormat.YVYU: default: throw new ArgumentException("Unsupported pixel type.", "format"); } }
public ConversionTable(SapFormat bufferFormat, int[] fileFormat) { m_BufferFormat = bufferFormat; m_FileFormat = fileFormat; }
public bool UpdateBuffer() { // Set load/save options if (!SetOptions()) { return(false); } m_PathName = m_FileDialog.FileName; if (m_pBuffer != null) { if (m_isOpen) { //Load File in the current buffer return(m_pBuffer.Load(m_PathName, m_StartFrame, m_Options)); } else { int conversionType = 0; SapFormat format = m_pBuffer.Format; for (int i = 0; i < m_ConversionTable.Length; i++) { if (m_ConversionTable[i].m_BufferFormat == format) { switch (m_Type) { case SapBuffer.FileFormat.BMP: conversionType = m_ConversionTable[i].m_FileFormat[0]; break; case SapBuffer.FileFormat.TIFF: conversionType = m_ConversionTable[i].m_FileFormat[1]; break; case SapBuffer.FileFormat.CRC: conversionType = m_ConversionTable[i].m_FileFormat[2]; break; case SapBuffer.FileFormat.RAW: conversionType = m_ConversionTable[i].m_FileFormat[3]; break; case SapBuffer.FileFormat.JPEG: conversionType = m_ConversionTable[i].m_FileFormat[4]; break; case SapBuffer.FileFormat.JPEG2000: conversionType = m_ConversionTable[i].m_FileFormat[5]; break; default: break; } break; } } if (conversionType > 0) { string message = ""; switch (conversionType) { case CONV_TO_MONO8: message = "Warning: data conversion to MONO8 has taken place to save the image in this file format"; break; case CONV_TO_RGB8: message = "Warning: data conversion to RGB888 has taken place to save the image in this file format"; break; case CONV_TO_RGB10: message = "Warning: data conversion to RGB101010 has taken place to save the image in this file format"; break; case CONV_TO_RGB16: message = "Warning: data conversion to RGB161616 has taken place to save the image in this file format"; break; } MessageBox.Show(message); } return(m_pBuffer.Save(m_PathName, m_Options, m_StartFrame, 0)); } } return(true); }
public SapFormatInfo(SapFormat format, string name) { m_Value = format; m_Name = name; }