HTML/CSS: Background Image from raw image data, not url

i get the raw image data of a png-image from a webserver, and want to use it as the background image of a div-element. is this possible without saving the data as an image-file first?

Answers


Use a data URI:

document.getElementById('e').src = 'data:image/png;base64,ton_of_crap';

In that Wikipedia article, there is code for PHP and Python that outputs base-64 encoded images. You can just shove that into the url() of a CSS file (or the src attribute of a <img /> tag) and it should work.


Have you tried (with jQuery):

$('#divID').css("background-image", "url(/myimage.png)");

From Switching a DIV background image with jQuery


Need Your Help

MySQL - convert and compare dates on query

php mysql date

I'm working on a football site witch, along with many features, list result tables. The tables are separated between seasons (season name, etc) and rounds (witch are generated everytime a new season

I have a machine with 8 GB RAM with 32 bit JVM on linux and i want to make JVM to use maximum USE OF RAM

java linux jvm

I have a machine with 8 GB RAM with 32 bit JVM on linux and i want to make JVM to use maximum USE OF RAM ,