public SKMask(IntPtr image, SKRectI bounds, UInt32 rowBytes, SKMaskFormat format) { fBounds = bounds; fRowBytes = rowBytes; fFormat = format; fImage = (byte *)image; }
public SKMask(SKRectI bounds, UInt32 rowBytes, SKMaskFormat format) { this.bounds = bounds; this.rowBytes = rowBytes; this.format = format; this.image = IntPtr.Zero; }
public SKMask(SKRectI bounds, UInt32 rowBytes, SKMaskFormat format) { fBounds = bounds; fRowBytes = rowBytes; fFormat = format; fImage = null; }
public static SKMask Create(byte[] image, SKRectI bounds, UInt32 rowBytes, SKMaskFormat format) { // create the mask var mask = new SKMask(bounds, rowBytes, format); // is there the right amount of space in the mask if (image.Length != mask.ComputeTotalImageSize()) { // Note: buffer.Length must match bounds.Height * rowBytes var expectedHeight = bounds.Height * rowBytes; var message = $"Length of image ({image.Length}) does not match the computed size of the mask ({expectedHeight}). Check the {nameof(bounds)} and {nameof(rowBytes)}."; throw new ArgumentException(message); } // copy the image data mask.AllocateImage(); Marshal.Copy(image, 0, mask.image, image.Length); // return the mask return(mask); }