Re: Best way to get a file path for presentation to the user
On 19 Dec 2015, at 09:51, Graham Cox wrote: > My use case is an interface that sets up a batch of files for saving in a > particular folder. The user chooses the folder using a standard NSOpenPanel, > but I want to display the chosen location in the UI so that they don’t need > to remember it. I don’t think a NSPathControl is really appropriate for this. What gives you that impression? That seems to be exactly what it was made for. > But I do want the string to be the most understandable for the user. I don’t > know really how many average users understand what ~/ means, but it’s > probably the best I can do. "~" is a nerd thing. If you're in any way in touch with whoever does your support, you don't want to add something this confusing to your GUI. What I did in UKFilePathView is just shorten the path at the start to a point of interest when displaying it, e.g. having the path display just start at the home folder and using the file icon to have the user recognize it is a user folder. Cheers, -- Uli Kusterer "The Witnesses of TeachText are everywhere..." http://stacksmith.org ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Bitmaps, colorspaces, etc.
I’m trying to understand how properly to use colorspaces with bitmaps. In my app’s Export function, we’d like to offer the ability to choose a colorspace for the exported image, in whatever format the user chose. My thoughts were to use NSBitmapImageRep to capture the image, then use its -representationUsingType:properties: method to get the image data in whatever format before writing it to disk. So far so good. NSBitmapImageRep accepts a ‘colorspaceName’ parameter when it’s created, and these can be one of the following: • NSCalibratedWhiteColorSpace • NSCalibratedBlackColorSpace • NSCalibratedRGBColorSpace • NSDeviceWhiteColorSpace • NSDeviceBlackColorSpace • NSDeviceRGBColorSpace • NSDeviceCMYKColorSpace • NSNamedColorSpace • NSCustomColorSpace Which are all strings, and seem to represent a very generic non-specific kind of colorspace. These don’t match with the colorspaces known to the system as returned by +[NSColorSpace availableColorSpacesWithModel:], which returns an array of NSColorSpace objects, each of which is able to return a -localizedName property, which are very specific, and do not relate to the above names at all. How do I bridge this impedance mismatch? If the user wants to Export using a specific, named colorspace, as chosen for example from a list of the colorspaces returned by the +availableColorSpaces method, how should I go about creating the appropriate bitmap? I see that NSBitmapImageRep has methods such as -bitmapImageRepByRetaggingWithColorspace: and -bitmapImageRepByConvertingToColorSpace:renderingIntent: What does ‘retagging’ mean? Presumably converting duplicates the bitmap, so could be a memory strain. This seems unnecessary if I could create the bitmap with a specific colorspace in the first place. Also, when creating a bitmap, what does using ‘NSNamedColorspace’ do? Which named colorspace? What about ‘NSCustomColorSpace’? These seem only to indicate what general kind of colorspace to expect, not a specific one. The problem here is that I can find no documentation that goes anywhere near explaining this. Maybe NSBitmapImageRep is too high level and I need to drop down to CGImageRef? That class does seem to take a specific CGColorSpace object, though how I get there from +[NSColorSpace availableColorSpecs] is unclear. Am I even asking sensible questions? This sort of impedance mismatch usually suggests a conceptual misunderstanding somewhere, but without a clear explanation of how colorspaces and bitmaps are used, I can’t see where I may have gone wrong. Anyone able to illuminate? —Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Bitmaps, colorspaces, etc.
> On 21 Dec 2015, at 09:15, Graham Cox wrote: > > I’m trying to understand how properly to use colorspaces with bitmaps. > > The problem here is that I can find no documentation that goes anywhere near > explaining this. Maybe NSBitmapImageRep is too high level and I need to drop > down to CGImageRef? That class does seem to take a specific CGColorSpace > object, though how I get there from +[NSColorSpace availableColorSpecs] is > unclear. That bit seems straightforward, you get the CGColorSpace property of the NSColorSpace object returned by NSColorSpace.availableColorSpacesWithModel() But if you want a bitmap to draw in then CGImageRef doesn’t seem like the right thing, CGBitmapContext takes a CGColorSpace (as long as it’s not an indexed one). If you need to bridge back to NSBitmapImageRef you should be able to do that via the CGBitmapContext’s CGImage property which is probably more efficient than you might fear. I can’t offer much for the rest of the questions, those hard-coded strings don’t mean much to me, I can’t see quite what you’d get if you passed the ‘custom’ string without being able to pass the actual custom one, which you can’t. Retagging and conversion probably do exactly what the names suggest and conversion probably does take up more memory and retagging probably goes in-place, hence the restriction on using the same type of colorspace. Having come from the iOS world, if I ever need any kind of bitmap or other low-level CG thing, I go right for the CG classes because the NS ones often don’t exist, I’ve found them to be pretty full-featured. > > Am I even asking sensible questions? This sort of impedance mismatch usually > suggests a conceptual misunderstanding somewhere, but without a clear > explanation of how colorspaces and bitmaps are used, I can’t see where I may > have gone wrong. > > Anyone able to illuminate? > > —Graham > > > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org > > This email sent to r...@rols.org ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Bitmaps, colorspaces, etc.
> On 21 Dec 2015, at 1:16 PM, Roland King wrote: > > That bit seems straightforward, you get the CGColorSpace property of the > NSColorSpace object returned by NSColorSpace.availableColorSpacesWithModel() > > But if you want a bitmap to draw in then CGImageRef doesn’t seem like the > right thing, CGBitmapContext takes a CGColorSpace (as long as it’s not an > indexed one). If you need to bridge back to NSBitmapImageRef you should be > able to do that via the CGBitmapContext’s CGImage property which is probably > more efficient than you might fear. Great, I’m making some headway now. Thanks! I’m not sure why I’d overlooked CGBitmapContextCreate - I guess having used the CGImageCreate stuff in the past I assumed that was the only API that created a raw image buffer in CG. Indeed, the CGBitmapContext kills several birds with one stone, and seems to work efficiently. I don’t need indexed colorspaces, RGB, CMYK and Gray are plenty enough. —Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com