On iOS, Is there a way to get the size of an ImageContext after creating it using UIGraphicsBeginImageContextWithOptions?

StackOverflow https://stackoverflow.com/questions/10781718

Pregunta

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?

¿Fue útil?

Solución

For a bitmap context as above you can use:

CGContextRef context = UIGraphicsGetCurrentContext();
size_t width = CGBitmapContextGetWidth(context);
size_t height = CGBitmapContextGetHeight(context);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top