When I try to create a CGCT FTPTF while trying to resize some images, I'm running on an issue I:
There are errors
Sun May 16 20:07:18 new-host.home app [7406] & lt; Error & gt;: unable to create a bitmap representative device Sun May 16 20:07: 18 new host of app [7406] & lt; Error & gt;: createBitmapContext: Failed to create a representative
My code looks like this
- (UIImage *) resizeImage: (UIImage *) Basic With Image Size: (CGSize) newSize {CGSize originalSize = originalImage size; CGFloat original estimate ratio = original size Width / Basics height; CGImageRef cgImage = Zero; Int bitmapWidth = newSize.width; Int bitmapHeight = newSize.height; CGColorSpaceRef colorpace = CGColorSpaceCreateDeviceRGB (); CGContextRef Reference = CGBitmapContextCreate (zero, bitmapwidth, bitmap height, 8, bitmap width * 4, in place of colors, KCGImage olfopimeteltlist); If (reference! = Zero) {// flip the coordinate system // CGContextScaleCTM (Reference, 1.0, -1.0); // CGContextTranslateCTM (Reference, 0.0, -ByightMapHight); // Black Background CGRect rect = CGRectMake (0, 0, bitmapWidth, bitmapHeight); CGContextSetRGBFillColor (Reference, 0, 0, 0, 1); CGContextFillRect (reference, rect); // To resize shape ratio // Resize box if (Basic estimation line <1.0) {rect.origin.y + = (rect.size.height - rect.size.width / originalAspectRatio) * 0.5; Rect.size.height = rect.size.width / originalAspectRatio; } And {rect.origin.x + = (rect.size.width - rect.size.height * original figure) * 0.5; Rect.size.width = rect.size.height * Basic estimate ratio; } CGContextSetInterpolationQuality (Reference, KCG Interpolation High); // Draw picture CGContextDrawImage (context, rect, [original image CGImage]); // image cgImage = CGBitmapContextCreateImage (reference); // Release References CGContextRelease (reference); } CGColorSpaceRelease (colorspace); UIImage * Result = [UIImage imageWithCGImage: cgImage]; CGImageRelease (cgImage); Return result; } You can not pass the zero as the first argument of CGBitmapContextCreate.
Comments
Post a Comment