CopyToArgb() public method

Copies the contents of the surface to a buffer of same dimensions.
The destination buffer should use the ARGB format represented by ArgbColor. Some basic checks will be done to disallow invalid buffer informations. However, it is the responsibility of the caller to provide a valid destination buffer.
The dimensions of the buffer specified by do not match those of the surface. The stride in does not match the width.
public CopyToArgb ( SurfaceData surfaceData ) : void
surfaceData SurfaceData Information on the destination buffer.
return void
コード例 #1
0
ファイル: ArgbSurface.cs プロジェクト: sgraf812/crystalmpq
        public unsafe ArgbSurface(Surface surface)
            : base(surface)
        {
            data = new byte[sizeof(uint) * Width * Height];

            fixed (byte* dataPointer = data)
                surface.CopyToArgb(new SurfaceData(Width, Height, (IntPtr)dataPointer, sizeof(uint) * Width));
        }
コード例 #2
0
ファイル: ArgbSurface.cs プロジェクト: Bootz/crystalmpq
        public unsafe ArgbSurface(Surface surface)
            : base(surface)
        {
            data = new byte[sizeof(uint) * Width * Height];

            fixed(byte *dataPointer = data)
            surface.CopyToArgb(new SurfaceData(Width, Height, (IntPtr)dataPointer, sizeof(uint) * Width));
        }
コード例 #3
0
ファイル: BLPViewer.cs プロジェクト: sgraf812/crystalmpq
        private Bitmap SurfaceToBitmap(Surface surface)
        {
            if (surface is JpegSurface)
            {
                var bitmap = new Bitmap(surface.CreateStream());

                SwapRedAndBlueChannels(bitmap);

                return bitmap;
            }
            else
            {
                var bitmap = new Bitmap(surface.Width, surface.Height, PixelFormat.Format32bppArgb);

                try
                {
                    var bitmapData = bitmap.LockBits(new Rectangle(0, 0, surface.Width, surface.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);

                    surface.CopyToArgb(new SurfaceData(bitmapData.Width, bitmapData.Height, bitmapData.Scan0, bitmapData.Stride));

                    bitmap.UnlockBits(bitmapData);

                    return bitmap;
                }
                catch { bitmap.Dispose(); throw; }
            }
        }