如何将图像转换为 CSS
How to convert an image to CSS
通常是相反的,但我是一个特殊的孩子。
所以我想知道将整个图像转换为 CSS-rendered 图像的最有效方法是什么,我制作了一个
的方法
Get the image (using PHP's image create from JPEG)
Get the width / height of the image
Loop the height of the image, then in that loop -- loop the width
In width loop, get the color of the current position (current loop iteration / height loop iteration (x,y))
Display in a div (width=1px;height=1px;rgb(r,g,b))
但这似乎需要很长时间来渲染,因为它显示了数千甚至数百万个 div 来渲染一个图像,所以我想知道是否有另一种方法可以通过获取 hex / rgb colors
来自图像。
在某种程度上 -- 寻找显示数据像素的最快方法,我知道 div
不是最好的方法,因为它用于保存数据等...
试试这个 http://spritegen.website-performance.org/ or http://spriteme.org/ 将您的图像转换为 sprite 并制作 CSS Sprite 生成器
通常是相反的,但我是一个特殊的孩子。
所以我想知道将整个图像转换为 CSS-rendered 图像的最有效方法是什么,我制作了一个
的方法Get the image (using PHP's image create from JPEG)
Get the width / height of the image
Loop the height of the image, then in that loop -- loop the width
In width loop, get the color of the current position (current loop iteration / height loop iteration (x,y)) Display in a div (width=1px;height=1px;rgb(r,g,b))
但这似乎需要很长时间来渲染,因为它显示了数千甚至数百万个 div 来渲染一个图像,所以我想知道是否有另一种方法可以通过获取 hex / rgb colors
来自图像。
在某种程度上 -- 寻找显示数据像素的最快方法,我知道 div
不是最好的方法,因为它用于保存数据等...
试试这个 http://spritegen.website-performance.org/ or http://spriteme.org/ 将您的图像转换为 sprite 并制作 CSS Sprite 生成器