IOS notes on image-to-pixel Conversion
No matter how the image is generated, it is read from the disk, obtained from other objects, or obtained from the current video memory.
Whether it is a similar image, UIImage or CGImage.
The Display dimensions are divided into two types: point-based and pixel-based.
If you find that the generated image has a "screen" when you draw, scale, or take an image, most of them are incorrect image sizes.
For UIImage, we can use img. scale to obtain the actual pixel-to-vertex ratio. For CGImageRef, we can use the following method to obtain the actual pixel size:
CGSize size = CGSizeMake (CGImageGetWidth (imgRef), CGImageGetHeight (imgRef ));
Up to now, there are three types of image ratios on the iPhone: @ 1x, @ 2x, and @ 3x. The specific device is also very simple. You can search for them online.
In addition, it should be noted that some functions help you solve the point-to-pixel ratio conversion, so you do not have to handle it yourself, for example, take the following:
Uigraphicsbeginimagecontextwitexceptions (CGSizeMake (sz. width/2, sz. height), NO, 0 );
Note that the last parameter is 0, indicating that the actual size is automatically processed.