Condividi tramite


CGContext.AsBitmapContext Metodo

Definizione

Esegue il cast di CGContext in un oggetto CGBitmapContext.

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

Restituisce

Commenti

Sebbene ci siano diversi tipi di tipi di CGContext (regolare, bitmap e PDF), Apple non supporta un modo per indicare a tali tipi. Alcuni oggetti CGContext sono effettivamente noti come oggetti CGBitmapContext in alcune situazioni (chiamando GetImageFromCurrentImageContext() dopo la creazione di un contesto con BeginImageContext(CGSize) o BeginImageContextWithOptions(CGSize, Boolean, nfloat)).

Questi sono davvero oggetti CGBitmapContext e convertendolo, gli sviluppatori di applicazioni possono accedere alle varie proprietà bitmap.

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
};

Si applica a