Simple Image Question..

Discussion in 'iOS Programming' started by xArtx, May 19, 2012.

  1. xArtx macrumors 6502a

    Joined:
    Mar 30, 2012
    #1
    Hi Guys,

    Just starting out here...

    Code:
                UIImage *myImage = [UIImage imageNamed:@"imageArt.PNG"];
                CGPoint imagePoint = CGPointMake(156, 53);
                [myImage drawAtPoint:imagePoint]; 
    
    Does this code read the image from the device's flash every time it occurs?
    If so, how can I separate it so the image is loaded just once and can be
    printed to the screen multiple times?

    Cheers, Art.
     
  2. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #2
    I happen to know this one off the top of my head because I wondered the same thing roughly a year ago, but I'll point out how I learned the answer:

    I checked Apple's docs.

    From Apple's UIImage Class Reference, in the section for the imageNamed: method
     
  3. xArtx thread starter macrumors 6502a

    Joined:
    Mar 30, 2012
    #3
    So it looks like I can reuse exactly the same three lines even if I print the picture to the screen a hundred times...
    Thanks :)
     
  4. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #4
    I am a little confused why you're using the other two lines instead of a UIImageView.
     
  5. xArtx thread starter macrumors 6502a

    Joined:
    Mar 30, 2012
    #5
    I'm drawing 11x11 pixel bitmap icons over a gps map drawn with quartz 2d.
    This is basically how I'm drawing the icon at the same screen point that a plain
    Point Of Interest dot would be displayed.

    I've read here:
    http://xcodenoobies.blogspot.com.au/2011/02/best-way-to-use-uiimageview-memory.html
    That this way to print images never frees the memory, but it also says it's faster than
    the alternative the tutorial demonstrates.
     

Share This Page