- (void*)getImageData:(UIImage*)image
{
void* imageData;
if (imageData == NULL)
imageData = malloc(4 * image.size.width * image.size.height);
CGColorSpaceRef cref = CGColorSpaceCreateDeviceRGB();
CGContextRef gc = CGBitmapContextCreate(imageData,
image.size.width,image.size.height,
8,image.size.width*4,
cref,kCGImageAlphaPremultipliedFirst);
CGColorSpaceRelease(cref);
UIGraphicsPushContext(gc);
[image drawAtPoint:CGPointMake(0.0f, 0.0f)];
UIGraphicsPopContext();
CGContextRelease(gc);
return imageData;
}
object-c实现获取一个图片像素点RGB值的代码
最新推荐文章于 2021-07-01 10:09:12 发布