Note that there are some explanatory texts on larger screens.

plurals
  1. POApp Crash due to Receive memory warning in CGContextDrawImage?
    primarykey
    data
    text
    <p>my app Crash due to Receive memory Warning.when i run app with instruments then i get the following leak memory issue . <img src="https://i.stack.imgur.com/rpe4y.png" alt="enter image description here"></p> <p>here is my full code of this method.</p> <pre><code> - (UIImage *)resizeImage:(UIImage *)orignalImage newWidth:(int)width newHeight:(int)height bgColor:(UIColor *)bgColor { CGRect newRect; if((orignalImage.size.width&gt;width) || (orignalImage.size.height&gt;height)) { float newWidth,newHeight; if(orignalImage.size.width&gt;orignalImage.size.height) { newWidth=width; newHeight=(height*orignalImage.size.height)/orignalImage.size.width; } else if(orignalImage.size.height&gt;orignalImage.size.width) { newWidth=(width*orignalImage.size.width)/orignalImage.size.height; newHeight=height; } else { newWidth=width; newHeight=height; } newRect.origin.x=(width-newWidth)/2; newRect.origin.y=(height-newHeight)/2; newRect.size.width=newWidth; newRect.size.height=newHeight; } else { newRect.origin.x=(width-(orignalImage.size.width))/2; newRect.origin.y=(height-(orignalImage.size.height))/2; newRect.size.width=orignalImage.size.width; newRect.size.height=orignalImage.size.height; } CGImageRef imageRef = [orignalImage CGImage]; CGImageAlphaInfo alphaInfo = CGImageGetAlphaInfo(imageRef); //if (alphaInfo == kCGImageAlphaNone) alphaInfo = kCGImageAlphaNoneSkipLast; CGContextRef bitmap = CGBitmapContextCreate(NULL, width, height, CGImageGetBitsPerComponent(imageRef), 4 * width, CGImageGetColorSpace(imageRef), alphaInfo); CGContextSetFillColorWithColor(bitmap, bgColor.CGColor); CGContextFillRect(bitmap, CGRectMake(0, 0, width, height)); CGContextDrawImage(bitmap, newRect, imageRef); CGImageRef newImgRef = CGBitmapContextCreateImage(bitmap); UIImage *newImg = [UIImage imageWithCGImage:newImgRef]; CGContextRelease(bitmap); CGImageRelease(newImgRef); return newImg; } </code></pre> <p>Some one can suggest me what mistake in my code.any help will be apprericated thanks.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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