Exemple #1
0
 public static Image <Color32> Parse(byte[] bytes)
 {
     try
     {
         var sgi   = SiliconGraphicsImage.ImageFromBytes(bytes);
         var img   = sgi as Image <byte>;
         var image = new Image <Color32>();
         image.Width    = img.Width;
         image.Height   = img.Height;
         image.Channels = img.Channels;
         image.Data     = new Color32[image.Width * image.Height];
         for (int i = 0, c = image.Width * image.Height; i < c; ++i)
         {
             ref Color32 color = ref image.Data[i];
             int         index = i * image.Channels;
             color.r = img.Data[index];
             color.g = (image.Channels > 1) ? img.Data[index + 1] : img.Data[index];
             color.b = (image.Channels > 2) ? img.Data[index + 2] : img.Data[index];
             color.a = (image.Channels > 3) ? img.Data[index + 3] : (byte)255;
         }
         return(image);
     }
Exemple #2
0
        public override void Execute()
        {
            base.Execute();
            var sgi = SiliconGraphicsImage.ImageFromBytes(FileBytes);

            if (sgi is Image <byte> )
            {
                var img = sgi as Image <byte>;
                Image.Width    = img.Width;
                Image.Height   = img.Height;
                Image.Channels = img.Channels;
                Image.Data     = new Color32[Image.Width * Image.Height];
                for (int i = 0, c = Image.Width * Image.Height; i < c; ++i)
                {
                    ref Color32 color = ref Image.Data[i];
                    int         index = i * Image.Channels;
                    color.r = img.Data[index];
                    color.g = (Image.Channels > 1) ? img.Data[index + 1] : img.Data[index];
                    color.b = (Image.Channels > 2) ? img.Data[index + 2] : img.Data[index];
                    color.a = (Image.Channels > 3) ? img.Data[index + 3] : (byte)255;
                }
                return;
            }