如何使progrmatically的Mac OS X ICNS使用SIPS或其他10图像不同的充 [英] How to progrmatically make Mac OS X ICNS with 10 differnt images using sips or other

查看:243
本文介绍了如何使progrmatically的Mac OS X ICNS使用SIPS或其他10图像不同的充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是,我需要有。我需要以编程方式达致这。

My issue is that i need have. I need to acheive this programatically.

因此​​,对于Mac OS X的应用程序图标应该具备以下尺寸:

So for mac os x an application icon should have these sizes:

我有10张图像。每一个我把徽章在右上角,布局和位置这个徽章并不规模。所以,我10个不同的图像。

I have 10 images. Each one i placed a badge in the right corner, the placement and position of this badge does not scale. So i 10 different images.

如何使一个ICNS出来的吗?

How to make a ICNS out of this?

我想使用的SIP,但是啜饮只需要一个文件,并完成所有的定标:<一href=\"http://cc.bingj.com/cache.aspx?q=mac+icns+sips+argument+list&d=5035141870911884&mkt=en-US&setlang=en-US&w=n3PZcWn6bEPxt4O96PPLd6nugtVq5jDz\" rel=\"nofollow\">http://cc.bingj.com/cache.aspx?q=mac+icns+sips+argument+list&d=5035141870911884&mkt=en-US&setlang=en-US&w=n3PZcWn6bEPxt4O96PPLd6nugtVq5jDz

I thought to use sips, however sips only takes one file and it does all the scalings: http://cc.bingj.com/cache.aspx?q=mac+icns+sips+argument+list&d=5035141870911884&mkt=en-US&setlang=en-US&w=n3PZcWn6bEPxt4O96PPLd6nugtVq5jDz

有没有一种方法,使的/ usr / bin中/ SIPS 把我的10张图像,并作出ICNS出来的吗?如果SIPS不能做到这一点是有没有其他办法?

Is there a way to make /usr/bin/sips take my 10 images and make a icns out of it? If sips cant do it is there any other way?

感谢

推荐答案

如果你想使用 iconutil ,你可以做到这一点。至少在我的10.9.5系统中,它的基本操作系统的一部分。这不是一个特殊的安装,就像开发工具。您可以验证通过:

If you want to use iconutil, you can do that. At least on my 10.9.5 system, it's part of the base OS. It's not a special install, like developer tools. You can verify that using:

pkgutil --file-info /usr/bin/iconutil

在这里,输出:

volume: /
path: /usr/bin/iconutil

pkgid: com.apple.pkg.BSD
pkg-version: 10.9.0.1.1.1306847324
install-time: 1402788942
uid: 0
gid: 0
mode: 755

最重要的部分是pkgid。它是在BSD包,这是基本OS的一部分的一部分。

The important part is the pkgid. It's part of the BSD package, which is part of the base OS.

这就是说,它不是很难写的有点code的做到这一点。

That said, it's not hard to write a bit of code to do this.

您可以使用CGDestination API。创建使用目的地 CGImageDestinationCreateWithURL()。对于键入,传 kUTTypeAppleICNS

You can use the CGDestination API. Create a destination using CGImageDestinationCreateWithURL(). For the type, pass kUTTypeAppleICNS.

既然你要添加的单个文件的图像,它可能最简单的创建一个 CGImageSource ,为每个 CGImageSourceCreateWithURL()。然后,您可以直接从源使用 CGImageDestinationAddImageFromSource()添加图像到目的地。不要忘了 CFRelease()您已经添加了图像到目标后,每个源。

Given that you want to add images from individual files, it's probably easiest to create a CGImageSource for each using CGImageSourceCreateWithURL(). Then, you can directly add an image from the source to the destination using CGImageDestinationAddImageFromSource(). Don't forget to CFRelease() each source after you've added its image to the destination.

然后,调用 CGImageDestinationFinalize()来有目的地写出来的图像的URL。然后, CFRelease()目标。

Then, call CGImageDestinationFinalize() to have the destination write out the image to the URL. Then, CFRelease() the destination.

如果每个源图像的具有适当的DPI集,这将被复制完好到目的地。如果源图像不具有适当的DPI设置,你可以通过属性的字典 CGImageDestinationAddImageFromSource覆盖它()。包括键 kCGImagePropertyDPIHeight kCGImagePropertyDPIWidth ,每一个相应的值 CFNumber 与所需的DPI对象。对于一个正常的分辨率的图标,使用72 DPI。对于高解析度(@ 2X)图标,请使用144 DPI。

If each of the source images has the proper DPI set, this will be copied over intact to the destination. If the source images don't have the proper DPI set, you can override it by passing a dictionary of properties to CGImageDestinationAddImageFromSource(). Include the keys kCGImagePropertyDPIHeight and kCGImagePropertyDPIWidth, each with a corresponding value of a CFNumber object with the desired DPI. For a normal-resolution icon, use 72 DPI. For a high-resolution (@2x) icon, use 144 DPI.

创建ICNS文件,也可以使用旧IconFamily API来完成,但它是一个有点毛。此外,它不支持高分辨率的图标

Creating ICNS files can also be done using the old IconFamily API, but it's a bit hairy. Also, it doesn't support high-resolution icons.

首先,创建一个句柄(指针到指针到可调整大小的缓冲区)的图标系列:

First, you create a handle (pointer-to-pointer-to-resizable-buffer) for the icon family:

IconFamilyHandle iconFamily = (IconFamilyHandle)NewHandle(0);

然后,对于每个图像尺寸(16,32,128,256,和512),则对图像数据的原始位图创建的手柄。该位应为每像素32位,每个组件8位,ARGB非premultiplied数据没有填充。

Then, for each image size (16, 32, 128, 256, and 512), you create a handle for a raw bitmap of the image data. The bitmap should be 32 bits per pixel, 8 bits per component, ARGB non-premultiplied data with no padding.

int size = /* 16, 32, 128, 256, or 512 */;
Handle handle = NewHandle(size * size * 4);
// fill handle with image data; buffer pointer is *handle

然后,添加图标句柄家庭像一个电话:

Then, you add that handle to the icon family with a call like:

SetIconFamilyData(iconFamily, kIconServices16PixelDataARGB, handle);

对于其他尺寸,用适当的值替换 kIconServices16PixelDataARGB 16。

然后,你写的图标系列手柄的数据到文件中。通过简单地提领手柄获得的数据指针(即 * iconFamily )。通过调用获得它的大小 GetHandleSize((手柄)iconFamily)

Then, you write the icon family handle's data out to file. A pointer to the data is obtained by simply dereferencing the handle (i.e. *iconFamily). Its size is obtained by calling GetHandleSize((Handle)iconFamily).

中的任何处置句柄可以通过调用沿途创建 DisposeHandle()

Dispose of any handles you created along the way by calling DisposeHandle().

这篇关于如何使progrmatically的Mac OS X ICNS使用SIPS或其他10图像不同的充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆