如何将图像转换为CSS

问题描述:

Usually it's the other way around, but I'm a special kid.

So I was wondering what the most efficient way was to convert an entire image to a CSS-rendered image, I made a method that would

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))

But that seems to take a really long time to render, as it's displaying thousands if not millions of divs to render the one image, so I was wondering if there was another way to display an image from getting the hex / rgb colors from an image.

In a way -- Looking for the quickest way to display a pixel of data, I understand a div isn't the best for that because it's meant to hold data, etc...

通常它是另一种方式,但我是一个特殊的孩子。 p>

获取图像( 使用PHP创建的JPEG图像) p>

获取图像的宽度/高度 p>

循环图像的高度,然后在该循​​环中 - 循环宽度 p>

在宽度循环中,获取当前位置的颜色(当前循环迭代/高度循环迭代(x,y)) 以div显示(宽度= 1px; height = 1px; rgb(r,g,b)) p> blockquote>

但这似乎需要很长时间来渲染,因为它显示数千甚至数百万 div渲染一个图像,所以我想知道是否有另一种显示图像的方法来从图像中获取 hex / rgb colors code>。 p>

In 一种方式 - 寻找显示d像素的最快方法 ata,我理解 div code>不是最好的,因为它意味着保存数据等...... strong> p> div>

Try this http://spritegen.website-performance.org/ or http://spriteme.org/ convert your images to sprite and making CSS Sprite Generator