Поделиться через


CGContext.AsBitmapContext Метод

Определение

Приводит CGContext к CGBitmapContext.

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

Возвращаемое значение

Комментарии

Хотя существуют различные виды CGContext (обычные, растровые изображения и PDF), Apple не поддерживает способ отличить их друг от друга. Некоторые объекты CGContext фактически известны как объекты CGBitmapContext в нескольких ситуациях (вызов GetImageFromCurrentImageContext() после создания контекста с BeginImageContext(CGSize) помощью или BeginImageContextWithOptions(CGSize, Boolean, nfloat)).

Это действительно объекты CGBitmapContext, и, преобразовав их, разработчики приложений могут получить доступ к различным свойствам растровых изображений на нем.

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

Применяется к