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

Spike099

macrumors regular
Original poster
Feb 18, 2007
143
0
Canada
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?
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
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).
 

cblackburn

macrumors regular
Jul 5, 2005
158
0
London, UK
It's probably best to have a view for each image.

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
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
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

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?
 

Spike099

macrumors regular
Original poster
Feb 18, 2007
143
0
Canada
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?
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Yes, you can create NSImageViews via the initWithFrame: method, and add them to another view via addSubview:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.