• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Scrolling List of Thumbnails?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scrolling List of Thumbnails?


  • Subject: Re: Scrolling List of Thumbnails?
  • From: Jerry LeVan <email@hidden>
  • Date: Fri, 18 Jun 2004 20:08:26 -0400

Below is my code for creating a scrolling list of images. The cells
are sized to 200x200.

Regrettably, the code is not swift and uses a lot of memory. One
of my directories contains almost 100 images of size 9-14 MB.

Top shows VM at almost one gig ( on my one gig g4 quicksilver 2002).

I would have thought that since the images are scaled to 200x200 that
the memory usage would not be nearly this high...Am I missing something?

"thumbArray" is really a one column matrix of "ActionImageCell"s (thanks John)
"filesLeft" is a text field in the FileCount nib, it displays the number
of files left to process. (displayIfNeeded was really needed :)

Jerry

- (IBAction)openFile:(id)sender
{
int fcnt; // number of files
int mcnt; // current size of thumbMatrix
int i; // counter
// Get list of files to process
NSOpenPanel *op = [NSOpenPanel openPanel];
[op setCanChooseDirectories:YES];
[op setCanChooseFiles:NO];

int returnCode = [op runModalForTypes:nil];
if (returnCode != NSOKButton) {
return;
}
NSString *path = [op filename];
NSMutableArray *tmp = [NSMutableArray arrayWithCapacity:10];
// get all of the filenames for images we understand in the directory
[self getFileList: tmp withPath:path];
if([tmp count] == 0) return; // no image files
[fileNameList setArray: tmp];
// Get the size of the filenamelist array
fcnt = [fileNameList count];
//Make sure we have enough items in the matrix
while( fcnt < [thumbArray numberOfRows]) { [thumbArray removeRow:[thumbArray numberOfRows]-1];}
while (fcnt > [thumbArray numberOfRows]) { [thumbArray addRow];}
// load the progress indicator...
if(!thePanel) {
[NSBundle loadNibNamed: @"FileCount" owner:self];
}
[thePanel orderFront:self];
[progressInd setUsesThreadedAnimation:YES];
[progressInd startAnimation:self];
fileCtr=fcnt;
for(i=0 ; i< fcnt ; i++) {
NSImage * tmp= [[NSImage alloc]initWithContentsOfFile:(NSString*)[fileNameList objectAtIndex:i]];
[[thumbArray cellAtRow:i column:0] setImage: tmp];
[[thumbArray cellAtRow:i column:0] setTarget:self];
[[thumbArray cellAtRow:i column:0] setAction:@selector(showMe:)];
[tmp release];
[filesLeft setIntValue: fileCtr--];
[filesLeft displayIfNeeded];
}
[progressInd stopAnimation:self];
[thePanel orderOut:self]; // hide the panel
if(displayedImage) { [displayedImage release]; displayedImage=NULL;}
[thumbArray sizeToCells];
[thumbArray setNeedsDisplay];
}
_______________________________________________
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.


  • Follow-Ups:
    • Re: Scrolling List of Thumbnails?
      • From: John Pannell <email@hidden>
  • Prev by Date: Re: [NSWindow invalidateShadow] dosen't works?
  • Next by Date: Converting Openstep nibs to Cocoa nibs?
  • Previous by thread: Re: Scrolling List of Thumbnails?
  • Next by thread: Re: Scrolling List of Thumbnails?
  • Index(es):
    • Date
    • Thread