1

就像 html 页面在文本编辑器中编码并保存为 .html 一样,我们可以通过编码 .jpg 文件来做同样的事情吗?jpg 文件是如何编码和构建的?

4

1 回答 1

2

正如 Jongware 在他的评论中所说,JPEG 是一种压缩方法。只需在文本编辑器中打开一个 JPEG 文件,您就会发现它看起来根本不像可以手工创建的东西。

如果要“编码”图像,则不能使用 JPEG 之类的位图图像格式-您需要矢量图像格式(有关差异的说明,请参见this)。

可能还有更多,但我想到的第一个是 SVG(关于 SVG 的维基百科文章)。

您在 XML 中“编码”SVG 文件,所有现代浏览器都能够呈现它。

这是一个示例,从上面的维基百科文章的德语版本中复制:(
英文文章没有可链接的渲染示例文件,只有源代码。所以我从德语文章中获取了示例,只是翻译了评论)

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
        version="1.1" baseProfile="full"
        width="700px" height="400px" viewBox="0 0 700 400">

        <!-- connectors left and right -->
        <line x1="0" y1="200" x2="700" y2="200" stroke="black" stroke-width="20px"/>
        <!-- the rectangle -->
        <rect x="100" y="100" width="500" height="200" fill="white" stroke="black" stroke-width="20px"/>
        <!-- the arrow line -->
        <line x1="180" y1="370" x2="500" y2="50" stroke="black" stroke-width="15px"/>
        <!-- the tip of the arrow -->
        <polygon points="585 0 525 25 585 50" transform="rotate(135 525 25)"/>
</svg>

渲染的图像如下所示:
http ://en.wikipedia.org/wiki/File:Variable_Resistor.svg

于 2013-10-19T10:18:28.447 回答