मैं रंग पीएनजी और अल्फा से धुंधला ग्रेस्केल UIImage
बनाने के लिए एक नुस्खा ढूंढने की कोशिश कर रहा हूं। ObjC में वहां व्यंजन हैं लेकिन मोनो टच CGRect
फ़ंक्शंस को बाध्य नहीं करता है, इसलिए यह सुनिश्चित न करें कि यह कैसे करें। कोई विचार?मोनो टच कलर यूआईएममेज को अल्फा के साथ ग्रेस्केल और ब्लर में कनवर्ट करें?
(UIImage *)convertImageToGrayScale:(UIImage *)image
{
// Create image rectangle with current image width/height
CGRect imageRect = CGRectMake(0, 0, image.size.width, image.size.height);
// Grayscale color space
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
// Create bitmap content with current image size and grayscale colorspace
CGContextRef context = CGBitmapContextCreate(nil, image.size.width, image.size.height, 8, 0, colorSpace, kCGImageAlphaNone);
// Draw image into current context, with specified rectangle
// using previously defined context (with grayscale colorspace)
CGContextDrawImage(context, imageRect, [image CGImage]);
// Create bitmap image info from pixel data in current context
CGImageRef imageRef = CGBitmapContextCreateImage(context);
// Create a new UIImage object
UIImage *newImage = [UIImage imageWithCGImage:imageRef];
// Release colorspace, context and bitmap information
CGColorSpaceRelease(colorSpace);
CGContextRelease(context);
CFRelease(imageRef);
// Return the new grayscale image
return newImage;
}
मैं इस सुविधा का उपयोग करने की कोशिश की, लेकिन यह से 1.0 पैमाने ... (टूटता अन्य छवियों के साथ काम नहीं करेगा रेटिना पर) – Jonny