Re: Scrolling an NSMatrix with 1000+ imageCells
Re: Scrolling an NSMatrix with 1000+ imageCells
- Subject: Re: Scrolling an NSMatrix with 1000+ imageCells
- From: Nat! <email@hidden>
- Date: Mon, 27 Jan 2003 18:36:19 +0100
Am Montag, 27.01.03 um 15:32 Uhr schrieb Florian Soenens:
Hello,
i posted this question a couple of days ago and got no response so
far, thus i will try again...
i have the following problem:
I subclassed NSMatrix to do my own mouse event handling. The NSMatrix
is part of a scroll view.
The matrix also has an NSMutableArray that contains images. (1000 or
more) Depending on the count of images, the Matrix rebuilds itself.
This goes all well. Then, i fill all the cells of the matrix with the
images of the array like this:
for(i = 0; i < [theArray count]; i++)
{
[[theMatrix cellAtRow:r column:c] setImage: [theArray
objectAtIndex:i];
}
Here comes the problem. (I'm actually not sure if it is a problem at
all, but it's frustrating nonetheless)
When all the images are set, and i scroll the matrix, the scrolling is
slow. (Dual G4 1GHZ) When i compare this to the scrolling speed of
iPhoto for example, it's 10x slower.
When i scrolled to the bottom completely, and then try again, the
scrolling goes a lot faster, cause the images have been displayed
already.
The question is: is there a way to let it scroll faster from the
beginning? Does it have something to do with caching ?
I would suspect yes, that NSImage initializes lazily. You should be
able to force a load by writing:
NSImage *image;
for(i = 0; i < [theArray count]; i++)
{
image = [theArray objectAtIndex:i];
[image representations];
[[theMatrix cellAtRow:r column:c] setImage:image];
}
This won't make it overall faster, but the slow scrolling effect oughta
vanish.
To make it overall faster, you might want to store a preview of the
image somewhere (may be in the -he he- resource fork of the image file)
and use this for your selection matrix.
Ciao
Nat!
------------------------------------------------------
But didn't I always tell you, honey, if I just stayed
in place and I never spoke up, good things are bound
to happen ? -- Jonathan Gems
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.