Пример #1
0
        public unsafe void BitBlt(BitmapSurface destinationBitmap, int top, int left, int height, int width)
        {
            lock (LockObject)
            {
                // Find smallest array
                //int size = (int)Math.Min(ByteLength, destinationBitmap.ByteLength) / destinationBitmap.BytesPerPixel;
                // Copy memory
                //CopyMemory(ImageData, destinationBitmap.ImageData, size);
                //Marshal.Copy(src, destinationBitmap.ImageData, 0, size);

                // First copy int64 as far as we can (faster than copying single bytes)
                Int64* src64 = (Int64*)ImageData;
                Int64* dst64 = (Int64*)destinationBitmap.ImageData;
                byte* src8 = (byte*)ImageData;
                byte* dst8 = (byte*)destinationBitmap.ImageData;

                int maxWidth  = Math.Min(Math.Min((int)Width  - left, (int)destinationBitmap.Width - left), width  + top);
                int maxHeight = Math.Min(Math.Min((int)Height - top,  (int)destinationBitmap.Height - top), height + top);

                for (int x = top; x < maxHeight; x++) {
                    for (int y = left; y < maxWidth; y++) {
                        int srcp = (x * (int)Width) + y;
                        int dstp = (x * (int)destinationBitmap.Width) + y;
                        dst8[dstp] = src8[srcp];
                    }
                }

            }

        }
Пример #2
0
        public unsafe void BitBlt(BitmapSurface destinationBitmap)
        {
            lock (LockObject)
            {
                // Find smallest array
                //int size = (int)Math.Min(ByteLength, destinationBitmap.ByteLength) / destinationBitmap.BytesPerPixel;
                // Copy memory
                //CopyMemory(ImageData, destinationBitmap.ImageData, size);
                //Marshal.Copy(src, destinationBitmap.ImageData, 0, size);

                // First copy int64 as far as we can (faster than copying single bytes)
                int copied = 0;
                Int64* src64 = (Int64*)ImageData;
                Int64* dst64 = (Int64*)destinationBitmap.ImageData;

                int srcHeight = (int)Height * (int)Width;
                int dstHeight = (int)destinationBitmap.Height * (int)destinationBitmap.Width;
                int maxLen = Math.Min(srcHeight, dstHeight);

                int copyLength = maxLen - 8;
                int i = 0;
                while (copied < copyLength)
                {
                    dst64[i] = src64[i];
                    i++;
                    copied += 8;
                }

                // Then copy single bytes until end of data
                byte* src8 = (byte*)ImageData;
                byte* dst8 = (byte*)destinationBitmap.ImageData;

                i *= 8;
                while (copied < ByteLength)
                {
                    dst8[i] = src8[i];
                    i++;
                    copied++;
                }

            }
        }
Пример #3
0
        public BitmapSurface Clone()
        {
            lock (LockObject)
            {
                // Create new bitmap
                var bitmap = new BitmapSurface(Width, Height, PixelFormat);
                // Copy data into new bitmap
                BitBlt(bitmap);

                return bitmap;
            }
        }