Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jyotsna.kadam

macrumors newbie
Original poster
Jan 29, 2009
4
0
Pune India
Hi,
i am developing a 2d game on iphone in which i want to maginify the views on the screen to give the effect that the user is looking through the sniper whenever the user taps the screen.. i am required to show that the objects which the player wants to shoot should be moving...so im incremeting their position as well as increasing their size... so i want this magnified image to show the updated positions of the moved objects at runtime to give the effect that the user is looking through the snpier...
i am trying to cut a image and mask it....that i am able to do successfully..but the program exits after few minutes with 101 status

- (void) maskImage
{

if(scopeOn==1)
{

UIGraphicsBeginImageContext(self.bounds.size);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
cachedImage=[UIImage imageNamed:mad:"loop.png"];
cachedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

imageRef = [cachedImage CGImage];

subImage = CGImageCreateWithImageInRect(imageRef,
CGRectMake(scopeLoc.x-25, scopeLoc.y-25, 50, 50));
xMaskedImage = CGImageCreateWithMask(subImage, mask);
zoomImg.image = [UIImage imageWithCGImage:xMaskedImage];
[zoomImg setCenter:scopeLoc];
[self addSubview:zoomImg];
CGImageRelease(subImage);
CGImageRelease(xMaskedImage);

}
}

this is the code that i am using....since i am not allocating explicit memory my guess is that CGImageCreateWithImageInRect function is allocating memory but it is not being released...this function is called after every 0.1 secs...so eventually a large amount of memoey is allocated(i have seen this in memory leak performance monitor)

So is there any other way in which i can achive the same wihtout this function??
Is there other way so I can get the magnified image and it can solve my memory issue also. Please reply me as soon as possible.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.