On iOS, Is there a way to get the size of an ImageContext after creating it using UIGraphicsBeginImageContextWithOptions?
-
11-06-2021 - |
Frage
If an image context is created using:
UIGraphicsBeginImageContextWithOptions(CGSizeMake(768, 768), YES, 1.0);
is there a way to get the size of the context later on? The size for sure is there when the image is obtained from the context, but while drawing, is there also a way to get the width and size of it?
Lösung
For a bitmap context as above you can use:
CGContextRef context = UIGraphicsGetCurrentContext();
size_t width = CGBitmapContextGetWidth(context);
size_t height = CGBitmapContextGetHeight(context);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow