Szerkesztés

Megosztás a következőn keresztül:


CGContext.AsBitmapContext Method

Definition

Casts the CGContext into a CGBitmapContext.

public CoreGraphics.CGBitmapContext AsBitmapContext ();
member this.AsBitmapContext : unit -> CoreGraphics.CGBitmapContext

Returns

Remarks

While there are different kinds of CGContext kinds (regular, bitmap and PDF), Apple does not support a way to tell those apart. Certain CGContext objects are actually known to be CGBitmapContext objects in a few situations (calling GetImageFromCurrentImageContext() after creating a context with BeginImageContext(CGSize) or BeginImageContextWithOptions(CGSize, Boolean, nfloat)).

Those are really CGBitmapContext objects and by converting it, application developers can access the various bitmap properties on it.

UIGraphics.BeginImageContextWithOptions (image.Size, false, UIScreen.MainScreen.Scale);
CGBitmapContext effectInContext = UIGraphics.GetCurrentContext ().AsBitmapContext ()

// Now, you can access some interesting properties like "Data", "Width", 
// "Height", "BytesPerRow" from the underlying bitmap

var effectInBuffer = new vImageBuffer () {
        Data = effectInContext.Data,
        Width = effectInContext.Width,
        Height = effectInContext.Height,
        BytesPerRow = effectInContext.BytesPerRow
};

Applies to