PDA

View Full Version : Single or Multiple NSImageViews




Spike099
Jun 29, 2007, 06:30 AM
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
Jun 29, 2007, 08:53 AM
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
Jun 29, 2007, 12:31 PM
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
Jun 29, 2007, 01:40 PM
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
Jun 29, 2007, 03:09 PM
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
Jun 29, 2007, 03:16 PM
Yes, you can create NSImageViews via the initWithFrame: method, and add them to another view via addSubview:

Spike099
Jun 29, 2007, 03:21 PM
Okay, thanks alot kainjow, i'll give that a try when I get home.

cblackburn
Jun 29, 2007, 06:46 PM
Are you displaying multiple images at once, like Spike099?

Yes, and I want to scale and place the images on the window as he wants but using CIImages rather than NSImages

Chris