Exemplo n.º 1
0
        internal virtual void EncodeLevel(VoidPtr dstAddr, DIB dib, Bitmap src, int dStep, int sStep, int level)
        {
            int mw = dib.Width, mh = dib.Height, aw = mw.Align(BlockWidth);

            if (level != 1)
            {
                dstAddr += GetMipOffset(ref mw, ref mh, level);
                using (Bitmap mip = src.GenerateMip(level))
                    dib.ReadBitmap(mip, mw, mh);
            }

            mw = mw.Align(BlockWidth);
            mh = mh.Align(BlockHeight);

            int bStride = mw * BitsPerPixel / 8;

            for (int y = 0; y < mh; y += BlockHeight)
            {
                VoidPtr sPtr = (int)dib.Scan0 + (y * dib.Stride);
                VoidPtr dPtr = dstAddr + (y * bStride);
                for (int x = 0; x < mw; x += BlockWidth, dPtr += dStep, sPtr += sStep)
                {
                    EncodeBlock((ARGBPixel *)sPtr, dPtr, aw);
                }
            }
        }
Exemplo n.º 2
0
        public static unsafe void CopyTo(this Bitmap bmp, Bitmap dest)
        {
            int w = Math.Min(bmp.Width, dest.Width);
            int h = Math.Min(bmp.Height, dest.Height);

            using (DIB dib = new DIB(w, h, dest.PixelFormat))
            {
                dib.ReadBitmap(bmp, w, h);
                dib.WriteBitmap(dest, w, h);
            }
        }