Note that there are some explanatory texts on larger screens.

plurals
  1. PORubyCocoa: Thumbnail Images in NSTableView
    primarykey
    data
    text
    <p>I'm trying to display an NSTableView of:</p> <p>| thumbnail | filename |</p> <p>I created the NSTableView in IB and delegated it to a class. In the class, I bypassed a model just to get a POC implementation and created the data source delegate methods. They populate the text cells just fine. However, now I'm at the step where the first cell needs to contain a small thumbnail of the image.</p> <p>What I want to do (and I'm sure it's stupid-simple) is grab the image icon -- and it's fair to assume that all files are jpegs and have thumbnails embedded -- and put that icon, scaled to 64x64 into the table cell. There's lots of code on how to generate thumbnails but I don't see much that gets me to working code. Here's what I have:</p> <pre><code> # This works if I am only populating text values in the when 'Image' def tableView_objectValueForTableColumn_row_(image_table, column, row) thumbnailImage(75) case column.headerCell.stringValue when 'File Name' (0..99).to_a[row].to_s when 'Image' # here's where I want to return a square 64x64 image or ImageCell thumbnailImage(64) else '???' end end # Creates square thumbnail def thumbnailImage(size) file = "file://localhost/Users/sxross/Downloads/iStock_000004561564XSmall.jpg" image = CGImageSourceCreateWithURL(CFURLCreateWithString(nil, file, nil), nil) thumb = CGImageSourceCreateThumbnailAtIndex(image, 0, nil) thumb end def numberOfRowsInTableView(view) 100 end </code></pre> <p>What I'm grappling with is what the missing steps are to get the thumbnailImage method to provide me with something that can be an appropriate data object to return from the data source.</p> <p>Any help is amazingly appreciated.</p> <p>BTW: IknowIknowIknow, I should be using MacRuby but it doesn't run on my 32-bit Core Duo. Sadly.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload