Example #1
0
        public static void JP2(string name, ResourceEntry re)
        {
            var entry = re as ResourceEntry_Image;

            try
            {
                var bytes = System.IO.File.ReadAllBytes(name);
                CSJ2K.Util.PortableImage img = CSJ2K.J2kImage.FromBytes(bytes);
                int[] ib    = img.GetComponent(0);
                int[] ig    = img.GetComponent(1);
                int[] ir    = img.GetComponent(2);
                var   image = new Image <Color32>();
                image.Width    = img.Width;
                image.Height   = img.Height;
                image.Channels = img.NumberOfComponents;
                image.Data     = new Color32[ib.Length];
                for (int i = 0, c = image.Width * image.Height; i < c; ++i)
                {
                    ref Color32 color = ref image.Data[i];
                    color.r = (byte)ir[i];
                    color.g = (byte)ig[i];
                    color.b = (byte)ib[i];
                    color.a = 255;
                }
                entry.Image = image;
            }
Example #2
0
        public byte[] Read(Tile tile)
        {
            string filename = Filename(tile);
            string logname  = "YearlyVstiRepresentation.Read(" + filename + ")";

            CSJ2K.Util.PortableImage img = CSJ2K.J2kImage.FromFile(filename);

            int[] ib = img.GetComponent(0);
            int[] ig = img.GetComponent(1);
            int[] ir = img.GetComponent(2);

            int dim = (int)Math.Sqrt(ib.Length);

            var result = new byte[tile.RasterDimension * tile.RasterDimension * 3];

            for (int y = 0; y < dim; ++y)
            {
                for (int x = 0; x < dim; ++x)
                {
                    int i = (y * dim) + x;
                    result[(i * 3) + 0] = (byte)ir[i];
                    result[(i * 3) + 1] = (byte)ig[i];
                    result[(i * 3) + 2] = (byte)ib[i];
                }
            }

            return(result);
        }
Example #3
0
 public override void Execute()
 {
     base.Execute();
     CSJ2K.Util.PortableImage img = CSJ2K.J2kImage.FromBytes(FileBytes);
     int[] ib = img.GetComponent(0);
     int[] ig = img.GetComponent(1);
     int[] ir = img.GetComponent(2);
     Image.Width    = img.Width;
     Image.Height   = img.Height;
     Image.Channels = img.NumberOfComponents;
     Image.Data     = new Color32[ib.Length];
     for (int i = 0, c = Image.Width * Image.Height; i < c; ++i)
     {
         ref Color32 color = ref Image.Data[i];
         color.r = (byte)ir[i];
         color.g = (byte)ig[i];
         color.b = (byte)ib[i];
         color.a = 255;
     }
Example #4
0
            public void Execute()
            {
                try
                {
                    // TODO: how do we get the size?

                    CSJ2K.Util.PortableImage img = CSJ2K.J2kImage.FromBytes(BytesNA.ToArray());

                    int[] ib = img.GetComponent(0);
                    int[] ig = img.GetComponent(1);
                    int[] ir = img.GetComponent(2);

                    int dim = (int)Math.Sqrt(ib.Length);

                    var result = new byte[dim * dim * 3];

                    for (int y = 0; y < dim; ++y)
                    {
                        for (int x = 0; x < dim; ++x)
                        {
                            int i = (y * dim) + x;
                            result[(i * 3) + 0] = (byte)ir[i];
                            result[(i * 3) + 1] = (byte)ig[i];
                            result[(i * 3) + 2] = (byte)ib[i];
                        }
                    }



                    var sgi  = new CDB.SiliconGraphicsImage();
                    var data = sgi.ReadRGB8("", BytesNA.ToArray(), out int w, out int h, out int c);
                    DataNA.CopyFrom(data);
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }