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)); }
/// <summary>Initializes a new instance of the <see cref="Surface"/> class by copying data from another <see cref="Surface"/>.</summary> /// <remarks> /// The base implementation in <see cref="Surface"/> only copies the common surface characteristics. /// Copying the actual surface data needs to be done by subclasses overriding this constructor. /// </remarks> /// <param name="surface">A reference surface which should be copied.</param> /// <exception cref="ArgumentNullException"><paramref name="surface"/> is <c>null</c>.</exception> protected Surface(Surface surface) { if (surface == null) throw new ArgumentNullException("surface"); this.width = surface.width; this.height = surface.height; this.alphaBitCount = surface.alphaBitCount; this.alphaPremultiplied = surface.alphaPremultiplied; }
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; } } }
protected override void Dispose(bool disposing) { if (disposing && @this != null) { @this.Dispose(); @this = null; } }
public Wrapper(Surface surface) : base(surface) { this.@this = surface; }