objective c - Multiple Image Operations Crash iPhone App -


I'm new to iPhone app development, so it's possible I'm doing something wrong.

Actually, I am loading a bunch of images from the Internet, and then crop them. I managed to find examples of loading asynchronous images and adding them to those sequences, I have succeeded by adding an image with a NSOata with NSData Which was included in the NSOperationQueue .

Then, because I had to make thumbs of fixed size, I wanted a way to crop these images, so I found a script on the net, which was originally called UIGraphicsBeginImageContext () , Uses UIGraphicsGetImageFromCurrentImageContext () and UIGraphicsEndImageContext () to attract the crop image, with unimportant size calculations

The thing is, the method works, but since it is 20 in these images, after some of them is produced, it randomly crashes, or the app closes once or twice And after some time to open again

What should I do in this case? I tried to run this method asynchronous in any way, along with, with NSOperations and NSOperationQueue , but no luck.

If the crop code is more relevant than I think, relevant here is:

  UIGFFransferEgeGetText (CGSIMMake (50, 50)); CGRTMARF = CGRxero; ThumbnailRect.origin = CP pointmaker (0.0.0.0); // This is actually generated / resized on the size of the source thumbnailRect.size.width = 50; ThumbnailRect.size.height = 50; [SourceImage drawInRect: thumbnailRect]; NewImage = UIGraphicsGetImageFromCurrentImageContext ();  

Thanks!

The code also appears to scale the images very simple here I am using as you You can see, there is no leak, now it is not necessary when the objects are released. Hope this will be helpful.

image

Integer) pixel width height: (int) pixelight {// Set the size of the output image CGRact = CGRactic make (0.0F, 0.0F, pixel width, pixelight); // Create a bitmap context to store the new thumbnail CGContextRef reference = MyCreateBitmapContext (pixelwidth, pixelhite); // clear the references and change the image to rectangle CGContextClearRect (reference, ARact); CGContextDrawImage (Reference, ARact, Image); // a new image image CGImageRef myRef = a UIImage populated with CGBitmapContextCreateImage (reference); UIImage * img = [UIImage imageWithCGImage: myRef]; Free (CGBitmapContextGetData (reference)); CGContextRelease (reference); CGImageRelease (myRef); Return img; } // MyCreateBitmapContext: Apple sample code based on source CGContextRef MyCreateBitmapContext (int pixel wide, high pixel high) {CGContextRef reference = faucet; CGColorSpaceRef colorpace; Zero * bitmap data; Int bitmapByteCount; Int bitmapBytesPerRow; BitmapBytesPerRow = (pixel wide * 4); BitmapByteCount = (bitmapBytesPerRow * pixelsHigh); ColorSpace = CGColorSpaceCreateDeviceRGB (); Bitmapdata = maulok (bitmapbitech); If (bitmapdata == faucet) {fprintf (stderr, "Memory Not Allowed!"); CGColorSpaceRelease (ColorSpace); Return tap; } Context = CGBitmapContextCreate (Bitmapdata, Pixel Wide, Pixel High, 8, BitmapBitSpiro, ColorSpace, KCGMJFelfMultiPilidLast); If (context == NULL) {free (bitmapdata); CGColorSpaceRelease (ColorSpace); Fprintf (stderr, "not made reference!"); Return tap; } CGColorSpaceRelease (colorSpace); Return reference; }


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -