Пример #1
0
        private void UpdatePalettePreview(ComboBox cmbPalette, PictureBox palettePreview)
        {
            byte[] palette = MedicalViewerCell.GetPalette((MedicalViewerPaletteType)cmbPalette.SelectedIndex);
            if (palette != null)
            {
                Color[] colorArray = new Color[palette.Length / 3];
                for (int i = 0; i < palette.Length; i += 3)
                {
                    colorArray[i / 3] = Color.FromArgb(palette[i], palette[i + 1], palette[i + 2]);
                }
                if (palettePreview.Image != null)
                {
                    palettePreview.Image.Dispose();
                    palettePreview.Image = null;
                }
                Image paletteImage = new Bitmap(palettePreview.Width, palettePreview.Height);
                FillImage(paletteImage, colorArray);

                palettePreview.Image = paletteImage;
            }
            else
            {
                palettePreview.Image = null;
            }
        }