Note that there are some explanatory texts on larger screens.

plurals
  1. POResizing UIImage in UIImageView
    primarykey
    data
    text
    <p>I'm trying to create a UIPickerView with some images in it, but I can't seem to figure out how to get the images to fit in the view (right now they're too large and are overlapping each other).</p> <p>I'm trying to use a function to resize each image when it's drawn, but I'm getting errors when the function is called, although the program compiles and runs fine (with the exception of the image not resizing). The resizing function and initialization functions are:</p> <pre><code>-(UIImage *)resizeImage:(UIImage *)image width:(int)width height:(int)height { NSLog(@"resizing"); CGImageRef imageRef = [image CGImage]; CGImageAlphaInfo alphaInfo = CGImageGetAlphaInfo(imageRef); //if (alphaInfo == kCGImageAlphaNone) alphaInfo = kCGImageAlphaNoneSkipLast; CGContextRef bitmap = CGBitmapContextCreate(NULL, width, height, CGImageGetBitsPerComponent(imageRef), 4 * width, CGImageGetColorSpace(imageRef), alphaInfo); CGContextDrawImage(bitmap, CGRectMake(0, 0, width, height), imageRef); CGImageRef ref = CGBitmapContextCreateImage(bitmap); UIImage *result = [UIImage imageWithCGImage:ref]; CGContextRelease(bitmap); CGImageRelease(ref); return result; } - (void)viewDidLoad { UIImage *h1 = [UIImage imageNamed:@"h1.png"]; h1 = [self resizeImage:h1 width:50 height: 50]; UIImageView *h1View = [[UIImageView alloc] initWithImage:h1]; NSArray *imageViewArray = [[NSArray alloc] initWithObjects: h1View, nil]; NSString *fieldName = [[NSString alloc] initWithFormat:@"column1"]; [self setValue:imageViewArray forKey:fieldName]; [fieldName release]; [imageViewArray release]; [h1View release]; } </code></pre> <p>Console Output:</p> <blockquote> <p>TabTemplate[29322:207] resizing</p> <p>TabTemplate[29322] : CGBitmapContextCreate: unsupported colorspace</p> <p>TabTemplate[29322] : CGContextDrawImage: invalid context</p> <p>TabTemplate[29322] : CGBitmapContextCreateImage: invalid context</p> </blockquote> <p>I can't figure out what's going wrong. Any help is greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload