简体   繁体   English

什么是获取资产目录矢量图像的最佳方法

[英]what is the best to way to get the vector image for asset catalog

I am aware xcode has introduced an option to provide a vector image(.pdf) so that we don't have to give a image for each dimension such as 1x,2x,3x 我知道xcode引入了提供矢量图像(.pdf)的选项,因此我们不必为每个尺寸(例如1x,2x,3x)提供图像

This saves lots of time and its really a good feature 这样可以节省大量时间,而且确实是一个很好的功能

But how to go about making an vector image in .pdf format. 但是如何制作.pdf格式的矢量图像。

As far as I know any png image can be saved as .pdf image does it mean it has been vectorized ? 据我所知,任何png图像都可以另存为.pdf图像,这是否意味着它已被矢量化?

or else we have to do it in the harder way .. by installing adobe illustrator and making an vector image through that 否则我们必须以更艰难的方式来做..通过安装adobe illustrator并通过它制作矢量图像

or else it there any web app that does it for us 否则,有任何网络应用程序可以为我们做到这一点

basically I want to do the right way so the when image is displayed in 3x devices also there is no image distortion 基本上我想做对了,所以当在3x设备中显示图像时也没有图像失真

This is a supplement to the excellent answer by @Senseful. 这是@Senseful出色回答的补充。

How to make vector images in .pdf format 如何制作.pdf格式的矢量图像

I will tell how to do this in Inkscape since it is free and open source but other programs should be similar. 我将告诉您如何在Inkscape中执行此操作,因为它是免费的开放源代码,但其他程序也应该类似。

In Inkscape: 在Inkscape中:

  1. Create a new project. 创建一个新项目。
  2. Go to File > Document Properties and set the custom page size to whatever your @1x size is (44x44, 100x100, etc) with the units in px. 转到“文件”>“文档属性”,然后将自定义页面大小设置为@ 1x大小(44x44、100x100等),单位为px。
  3. Make your artwork. 制作艺术品。
  4. Go to File > Save As... > Printable Document Format (*.pdf) > Save > OK. 转到文件>另存为...>可打印文档格式(* .pdf)>保存>确定。 (Alternatively, you could go to Print > Print to File > Output format: PDF > Print but there are not as many options.) (或者,您可以转到打印>打印到文件>输出格式:PDF>打印,但是没有那么多的选项。)

Notes: 笔记:

  • As is mentioned in the accepted answer, you cannot resize your image because Xcode still produces the rasterized images at build time. 如已接受的答案中所述,您无法调整图像大小,因为Xcode在生成时仍会生成栅格化图像。 If you need to resize your image you should make a new .pdf file with a different size. 如果需要调整图像大小,则应制作一个具有不同大小的新.pdf文件。
  • If you already have an .svg image that is the wrong page size, do the following: 如果您已经具有错误的页面大小的.svg图像,请执行以下操作:

    1. Change the page size (Inkscape > File > Document Properties) 更改页面大小(Inkscape>文件>文档属性)
    2. Select all objects (Ctrl+A) on the work space and resize them to fit in the new page size. 选择工作空间上的所有对象(Ctrl + A),然后调整它们的大小以适合新的页面大小。 (Hold down Ctrl to keep aspect size.) (按住Ctrl键可保持外观尺寸不变。)
  • To convert an .svg file into a .pdf you can also find online utilities to do the job for you. 要将.svg文件转换为.pdf,您还可以找到在线实用程序来为您完成这项工作。 Here is one example from this answer . 这是 这个答案的 一个例子 This has the benefit of allowing you to set the .pdf size easily. 这样的好处是允许您轻松设置.pdf大小。

Further reading 进一步阅读

Original answer 原始答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM