Access to <img> pixels

T

Tim Streater

If I create an image thus:

var myImg = new Image ();

I can then do the following:

myImg.src = "someimage.jpg";

But, I can't seem to find a way to manipulate the pixels of the image in
myImg (say, to invert each one).

Equally, if I have image data that I have read in from a database
record, I don't seem to find a way to stuff that directly into myImg.

Is this all actually the case or have I overlooked something?
 
B

Bjoern Hoehrmann

* Tim Streater wrote in comp.lang.javascript:
If I create an image thus:

var myImg = new Image ();

I can then do the following:

myImg.src = "someimage.jpg";

But, I can't seem to find a way to manipulate the pixels of the image in
myImg (say, to invert each one).

Equally, if I have image data that I have read in from a database
record, I don't seem to find a way to stuff that directly into myImg.

Is this all actually the case or have I overlooked something?

This is all actually the case, you might want to look at SVG or the
proposals around "<canvas>". You could also use the 'data' URL scheme
and manipulate the string to manipulate the pixels, as an example,
http://www.bjoernsworld.de/temp/gif-palette-animation-in-js.html.gz
does just that.
 
T

Tim Streater

Bjoern Hoehrmann said:
* Tim Streater wrote in comp.lang.javascript:

This is all actually the case, you might want to look at SVG or the
proposals around "<canvas>". You could also use the 'data' URL scheme
and manipulate the string to manipulate the pixels, as an example,
http://www.bjoernsworld.de/temp/gif-palette-animation-in-js.html.gz
does just that.

Now this, might be just what the doctor ordered.

Thanks - I shall give that scheme a try!
 
V

VK

Now this, might be just what the doctor ordered.

Thanks - I shall give that scheme a try!

Being warned that neither of IE versions supports that so Web-wide the
solution will work only for 10-20% of your visitors depending on the
world region. Can be not important for an intranet solution but
important to know for an open project.
 
T

Tim Streater

VK said:
Being warned that neither of IE versions supports that so Web-wide the
solution will work only for 10-20% of your visitors depending on the
world region. Can be not important for an intranet solution but
important to know for an open project.

Thanks for the heads-up. This would be for a closed user group so I may
have some flexibility.
 
D

david.karr

If I create an image thus:

var myImg = new Image ();

I can then do the following:

myImg.src = "someimage.jpg";

But, I can't seem to find a way to manipulate the pixels of the image in
myImg (say, to invert each one).

Equally, if I have image data that I have read in from a database
record, I don't seem to find a way to stuff that directly into myImg.

Is this all actually the case or have I overlooked something?

It seems like this is something you could achieve with a Java applet.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,141
Messages
2,570,818
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top