首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将画布上的绘图转换为icns

将画布上的绘图转换为icns
EN

Stack Overflow用户
提问于 2014-08-26 17:29:54
回答 1查看 85关注 0票数 0

可以将画布上的图形转换为.icns for Mac吗?

有人知道linux使用什么图标格式吗?

EN

回答 1

Stack Overflow用户

发布于 2014-08-27 16:28:17

关于linux使用哪种图标类型的问题的答案

我认为linux使用png图像作为图标。有没有人可以在评论中核实一下。

关于如何转换为.icns的问题的解答

如果任何人有任何其他的方式,请分享,我喜欢看到不同的方式做同样的事情,并看到它们之间的差异/怪癖。

要在mac中转换为.icns,需要在mxr上完成:http://mxr.mozilla.org/mozilla-release/source/toolkit/webapps/MacNativeApp.js#291

这是经过编辑的代码,因此它在上面的mxr范围之外工作。

代码语言:javascript
复制
/**
* @param aIcon         nsIFile :: of icon
* @param aPath         String :: where you want to save the image and with what name
*/
_processIcon: function(aIcon, aPath) {
  let deferred = Promise.defer();

  //let tmpIconPath = OS.Path.join(aDir, this.iconFile);

  function conversionDone(aSubject, aTopic) {
    if (aTopic != "process-finished") {
      deferred.reject("Failure converting icon, exit code: " + aSubject.exitValue);
      return;
    }

    // SIPS silently fails to convert the icon, so we need to verify if the
    // icon was successfully converted.
    OS.File.exists(aPath).then((aExists) => {
      if (aExists) {
        deferred.resolve();
      } else {
        deferred.reject("Failure converting icon, unrecognized image format");
      }
    });
  }

  let process = Cc["@mozilla.org/process/util;1"].
                createInstance(Ci.nsIProcess);
  let sipsFile = FileUtils.getFile("/usr/bin/sips");

  process.init(sipsFile);
  process.runAsync(["-s", "format", "icns",
                    aIcon.path,
                    "--out", aPath,
                    "-z", "128", "128"],
                    9, conversionDone);

  return deferred.promise;
}

我还不能测试它,因为我还没有mac vm,但希望它没有我在windows上做的那样的质量问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25502417

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档