获取垃圾桶的全尺寸图标
我正在尝试在我的应用程序中显示垃圾箱的图标,包括空的和满的。我尝试了多种方法来获取图标,但每次的大小都是 32x32。您知道获得全尺寸图像的方法吗?
I am trying to display the icons of the Trash can in my app, both empty and full. I've tried several methods to get the icons, but each time the size is 32x32. Do you know a way to get a full size image?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我假设您通过 NSWorkspace 获取垃圾桶图标,使用 IconsCore.h 中的
kTrashIcon
常量(如果不是,则为:…这个 NSImage 包含多种不同尺寸的表示形式。如果您想要最大的,只需迭代可用的表示即可找到它:
…在我的计算机上,这会导致 NSImage 设置为 512x512。
I assume that you’re getting the trash icon through NSWorkspace, using the
kTrashIcon
constant from IconsCore.h (if you’re not, this is :…this NSImage contains representations in a number of different sizes. If you want the biggest one, just iterate through the available representations to find it:
…On my computer, this results in an NSImage set to 512x512.
如果您要从以下文件创建图像,请注意 32px x 32px 只是默认尺寸
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/TrashIcon.icns
: 将其调整为您想要的大小:
当您这样做时,
NSImage
将自动从可用的图像代表中选择适当的图像代表。例如,记录图像会显示以下描述:大多数代表文件图标的图像(例如
NSWorkspace
返回的图像)将有多种可用尺寸,但默认尺寸为 32 x 32。If you're creating an image from the following file, then realize that 32px x 32px is simply the default size:
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/TrashIcon.icns
Just resize it to the size you'd like:
When you do so, the
NSImage
will automatically choose the appropriate image rep from those that are available. For example, logging the image shows the following description:Most images that represent file icons such as those returned by
NSWorkspace
will have many sizes available, though 32 x 32 is the default size./System/Library/CoreServices/Dock.app/Contents/Resources/trashfull.png
/System/Library/CoreServices/Dock.app/Contents/Resources/trashempty.png
这是 128x128 的图标
/System/Library/CoreServices/Dock.app/Contents/Resources/trashfull.png
/System/Library/CoreServices/Dock.app/Contents/Resources/trashempty.png
It's 128x128 icon
在 Google 图片上搜索“Mac OS 垃圾”
Search "Mac OS Trash" on Google Images