Beispiel #1
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 public MipMap(MipMap mipmap)
 {
     Width  = mipmap.Width;
     Height = mipmap.Height;
     Pixels = new byte[Width * Height * 4];
     Array.Copy(mipmap.Pixels, Pixels, Pixels.Length);
 }
Beispiel #2
0
        /// <summary>
        /// Gets the pixels as an raw BGRA32 byte array.
        /// </summary>
        public byte[] GetPixelsRaw(int mipmap = 0)
        {
            if (mipmap >= MipMaps.Count || mipmap < 0)
            {
                throw new IndexOutOfRangeException("Mipmap index out of range!");
            }
            MipMap mm = MipMaps[mipmap];

            return(mm.Pixels);
        }
Beispiel #3
0
        /// <summary>
        /// Gets the pixels as an Color4 array.
        /// </summary>
        public Color4[] GetPixels(int mipmap = 0)
        {
            if (mipmap >= MipMaps.Count || mipmap < 0)
            {
                throw new IndexOutOfRangeException("Mipmap index out of range!");
            }
            MipMap mm = MipMaps[mipmap];

            Color4[] result = new Color4[mm.Width * mm.Height];
            int      index  = 0;

            for (int i = 0; i < result.Length; i++)
            {
                index        = i * 4;
                result[i].B_ = mm.Pixels[index];
                result[i].G_ = mm.Pixels[index + 1];
                result[i].R_ = mm.Pixels[index + 2];
                result[i].A_ = mm.Pixels[index + 3];
            }
            return(result);
        }
Beispiel #4
0
        private void GetFromBitmap(Bitmap bitmap)
        {
            Bitmap bmp = new Bitmap(bitmap);

            Width  = bmp.Width;
            Height = bmp.Height;

            MipMap mipMap = new MipMap(Width, Height);

            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    Color col   = bmp.GetPixel(x, y);
                    int   index = (y * Width + x) * 4;
                    mipMap.Pixels[index]     = col.B;
                    mipMap.Pixels[index + 1] = col.G;
                    mipMap.Pixels[index + 2] = col.R;
                    mipMap.Pixels[index + 3] = col.A;
                }
            }
            MipMaps.Add(mipMap);
        }
Beispiel #5
0
        protected override void _Read(BinaryReader reader)
        {
            Image  image = Image.FromStream(reader.BaseStream);
            Bitmap bmp   = new Bitmap(image);

            Width  = bmp.Width;
            Height = bmp.Height;

            MipMap mipMap = new MipMap(Width, Height);

            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    Color col   = bmp.GetPixel(x, y);
                    int   index = (y * Width + x) * 4;
                    mipMap.Pixels[index]     = col.B;
                    mipMap.Pixels[index + 1] = col.G;
                    mipMap.Pixels[index + 2] = col.R;
                    mipMap.Pixels[index + 3] = col.A;
                }
            }
            MipMaps.Add(mipMap);
        }