Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-10-2009, 02:22 AM   #1 (permalink)
iPhone Developer
 
Join Date: May 2009
Location: India
Age: 25
Posts: 79
Send a message via Skype™ to AmitSrivastava
Default png images in memory.??

hi everyone,
am facing a problem, in my game i am using 80-90 png images of different size. The problem is that game is slow and unplayable, is there any difference if I crush png images and then use with "imageNamed:" ...... before I used "imageWithContentsofFile" .... but it had taken lots of time to load...

Is there any way to solve this prob

Thanx in advance ..
AmitSrivastava is offline   Reply With Quote
Old 07-10-2009, 02:58 AM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

Quote:
Originally Posted by AmitSrivastava View Post
hi everyone,
am facing a problem, in my game i am using 80-90 png images of different size. The problem is that game is slow and unplayable, is there any difference if I crush png images and then use with "imageNamed:" ...... before I used "imageWithContentsofFile" .... but it had taken lots of time to load...

Is there any way to solve this prob

Thanx in advance ..
Were you calling "imageWithContentsofFile" every frame? You probably need to load your images into an array at startup, and then reference them each frame without recreating them.

"imageNamed" is faster when you recreate the same image over and over, but you should not need to recreate them over and over; also imageNamed uses more memory (to cache the images.)

Also, how big are the images? If they are full-screen you'll probably only get about 20 images loaded at once before you run out of memory.
__________________

Free Games!
smasher is offline   Reply With Quote
Old 07-10-2009, 03:14 AM   #3 (permalink)
iPhone Developer
 
Join Date: May 2009
Location: India
Age: 25
Posts: 79
Send a message via Skype™ to AmitSrivastava
Default

Quote:
Originally Posted by smasher View Post
Were you calling "imageWithContentsofFile" every frame? You probably need to load your images into an array at startup, and then reference them each frame without recreating them.

"imageNamed" is faster when you recreate the same image over and over, but you should not need to recreate them over and over; also imageNamed uses more memory (to cache the images.)

Also, how big are the images? If they are full-screen you'll probably only get about 20 images loaded at once before you run out of memory.
Thanks for reply,
i am not recreating the images, i have stored in a NSMutable Array and using index of that Array,
Code:
- (void) initImages{
       XImg = [UIImage imageNamed:@"X.png"];
	[Xmages  addObject:XImg ];	
// 33 times	
}

- (void) XImage{		
	Ximageview.image = [Xmages objectAtIndex:XImageCount];
	
	XImageCount++;
	if(XImageCount>=33){
		XImageCount=0;	
	}
}
above all 33 image covers 70% of iPhone screen.

if i compress the png file, will it create any dfference?
AmitSrivastava is offline   Reply With Quote
Old 07-10-2009, 11:32 AM   #4 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

Quote:
Originally Posted by AmitSrivastava View Post
above all 33 image covers 70% of iPhone screen.

if i compress the png file, will it create any dfference?
Good, you are not recreating the images. I do not think compressing the images will affect the speed.

You could try Ximageview.animationImages = Xmages ; that may run smoother than setting the image by hand.
__________________

Free Games!
smasher is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Stats
Members: 158,307
Threads: 89,033
Posts: 379,817
Top Poster: BrianSlick (7,086)
Welcome to our newest member, percent17
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:57 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0