   PNG on the Iphone
  Hey I have been writing a game on the iphone using mostly C++ and have encountered a few problems with the PNG loader functionality of the iphone. So I was hoping to write my own anyone have any ideas where to get info on how to do this or ideas as to how I should go about doing it? Any help would be appreciated. Thanks!-SEmmerich   
  my texture opening code is straight out of the samples/documentation.   // open the file specified by the filename  NSUInteger len = strlen(a_filename);  NSString* filename = [[NSString alloc] initWithBytes:a_filename length:len encoding:NSASCIIStringEncoding];  o_imageRef = [UIImage imageNamed:filename].CGImage;    // if the file opened correctly, we setup the opengl texture  if(o_imageRef)  {    m_width = CGImageGetWidth(o_imageRef);    m_height = CGImageGetHeight(o_imageRef);    data = (GLubyte*) malloc( m_width * m_height * 4);    // create a quartz rendering context    o_context = CGBitmapContextCreate(data, m_width, m_height, 8, 4*m_width,CGImageGetColorSpace(o_imageRef), kCGImageAlphaPremultipliedLast);    // render the loaded image to the context, this effectively copys the data to our opengl surface    CGContextDrawImage(o_context, CGRectMake(0.0, 0.0, (CGFloat)m_width, (CGFloat)m_height), o_imageRef);    // release the context    CGContextRelease(o_context);    come on! its  in the docs ;  Use picopng. Beware that xcode apparently modifies png files on the sly, which causes picopng problems, so you need to rename the file extension   ;  What does it do to PNGs? I've been having a hard time getting my memory management down and it appears that how I'm creating images is part of the problem.The following code seemed pretty straightforward but looking in the ObjectAlloc of Instruments reveals that it's using up all kinds of memory for seemingly no reason. Most notably, it creates strings with NSBundle, and png_malloc is all over the place with large number associated with img_data_lock. The messed up thing is that the more I try to contain the memory usage, the more it's using.UIImageView *bottom_bg = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 50.0f)];image = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bottomhud_bg" ofType:@"png"]];[bottom_bg setImage:image];[image release];[self addSubview:bottom_bg];[bottom_bg release];