Single or Multiple NSImageViews

Discussion in 'Mac Programming' started by Spike099, Jun 29, 2007.

  1. macrumors regular

    Joined:
    Feb 18, 2007
    Location:
    Canada
    #1
    Hey guys,

    I am creating a program where a user can import multiple images. When the images have been loaded, the user can click on the images and they'll move around, be highlighted etc.

    Should I be using a single NSImageView for each image or create one large custom view and draw the images directly on that?

    If it's better to create a single NSImageView, how do I go about allocating an array of NSImageViews?
     
  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    It's probably best to have a view for each image. Then, Cocoa can cache them each separately and will be smarter at redrawing. Later on though when you have it all working, you will want to watch your memory usage and probably not store the images in memory but instead write them to disk and read them back from disk when needed (I have done a similar thing and reading/writing from disk saves a lot of memory).
     
  3. macrumors regular

    Joined:
    Jul 5, 2005
    Location:
    London, UK
    #3
    Really? I'm gonna have to code something like this soon, but my customers want to have the option of applying Core Image filters to the images so I'll be doing it with CIImages and NSOpenGLViews. Do you think I would be better off with multiple NSOpenGLViews or creating a Custom subclass to manage them all?

    Chris
     
  4. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    I'm not sure what your setup is like, so it depends. I haven't done much with NSOpenGLViews before. Are you displaying multiple images at once, like Spike099?
     
  5. thread starter macrumors regular

    Joined:
    Feb 18, 2007
    Location:
    Canada
    #5
    Okay, multiple NSImageViews it is.

    Now... Is it possible to create an array of views so that the user can add images at will and views will be created accordingly? Should I use an NSArrayController to manage the views?
     
  6. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #6
    Yes, you can create NSImageViews via the initWithFrame: method, and add them to another view via addSubview:
     
  7. thread starter macrumors regular

    Joined:
    Feb 18, 2007
    Location:
    Canada
    #7
    Okay, thanks alot kainjow, i'll give that a try when I get home.
     
  8. macrumors regular

    Joined:
    Jul 5, 2005
    Location:
    London, UK
    #8
    Yes, and I want to scale and place the images on the window as he wants but using CIImages rather than NSImages

    Chris
     

Share This Page