Exemple #1
0
        private void ImageListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (m_vm.image == null)
            {
                return;
            }

            string filename = m_vm.image.FilePath;

            m_imageData = Zip.Decompress_File(filename);

            if (m_imageData != null)
            {
                ushort width  = (ushort)Math.Sqrt(m_imageData.Length);
                ushort height = width;

                if (width != m_vm.width || height != m_vm.height)
                {
                    m_vm.width  = width;
                    m_vm.height = height;
                    m_vm.bitmap = BitmapFactory.New(m_vm.width, m_vm.height);
                }

                m_imageTool.PostFullGrayscaleImage(m_imageData, width, height);

                m_imageTool.Convert_GrayscaleToColor(m_rangeLower, m_rangeUpper);

                m_imageTool.Download_ColorImage(out m_colorImageData, m_vm.width, m_vm.height);

                // display the image
                Int32Rect displayRect = new Int32Rect(0, 0, m_vm.width, m_vm.height);
                m_vm.bitmap.Lock();
                m_vm.bitmap.WritePixels(displayRect, m_colorImageData, m_vm.width * 4, 0);
                m_vm.bitmap.Unlock();
            }
        }
Exemple #2
0
        private void FileListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (FileListBox.SelectedItem.GetType() == typeof(ImageFileViewer_Struct))
            {
                ImageFileViewer_Struct item = (ImageFileViewer_Struct)FileListBox.SelectedItem;
                string filename             = item.fullPath;
                string display = item.displayName;

                m_imageData = Zip.Decompress_File(filename);

                if (m_imageData != null)
                {
                    ushort width  = (ushort)Math.Sqrt(m_imageData.Length);
                    ushort height = width;

                    if (width != m_vm.width || height != m_vm.height)
                    {
                        m_vm.width  = width;
                        m_vm.height = height;
                        m_vm.bitmap = BitmapFactory.New(m_vm.width, m_vm.height);
                    }

                    m_imageTool.PostFullGrayscaleImage(m_imageData, width, height);

                    m_imageTool.Convert_GrayscaleToColor(m_rangeLower, m_rangeUpper);

                    m_imageTool.Download_ColorImage(out m_colorImageData, m_vm.width, m_vm.height);

                    // display the image
                    Int32Rect displayRect = new Int32Rect(0, 0, m_vm.width, m_vm.height);
                    m_vm.bitmap.Lock();
                    m_vm.bitmap.WritePixels(displayRect, m_colorImageData, m_vm.width * 4, 0);
                    m_vm.bitmap.Unlock();
                }
            }
        }