469,306 Members | 2,531 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

Access to <img> pixels

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?
Jun 27 '08 #1
5 2000
* 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-...-in-js.html.gz
does just that.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Jun 27 '08 #2
In article
<1k********************************@hive.bjoern.ho ehrmann.de>,
Bjoern Hoehrmann <bj****@hoehrmann.dewrote:
* 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-...-in-js.html.gz
does just that.
Now this, might be just what the doctor ordered.

Thanks - I shall give that scheme a try!
Jun 27 '08 #3
VK
On May 27, 5:13 pm, Tim Streater <tim.strea...@dante.org.ukwrote:
In article
<1k1o34tl0men0ov9o4d0q6g4k6lk9tf...@hive.bjoern.ho ehrmann.de>,
Bjoern Hoehrmann <bjo...@hoehrmann.dewrote:
* 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-...-in-js.html.gz
does just that.

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.
Jun 27 '08 #4
In article
<c9**********************************@r66g2000hsg. googlegroups.com>,
VK <sc**********@yahoo.comwrote:
On May 27, 5:13 pm, Tim Streater <tim.strea...@dante.org.ukwrote:
In article
<1k1o34tl0men0ov9o4d0q6g4k6lk9tf...@hive.bjoern.ho ehrmann.de>,
Bjoern Hoehrmann <bjo...@hoehrmann.dewrote:
* 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-...-in-js.html.gz
does just that.
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.
Thanks for the heads-up. This would be for a closed user group so I may
have some flexibility.
Jun 27 '08 #5
On May 27, 6:00 am, Tim Streater <tim.strea...@dante.org.ukwrote:
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.
Jun 27 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by Philipp Lenssen | last post: by
5 posts views Thread by MyndPhlyp | last post: by
9 posts views Thread by Wladimir Borsov | last post: by
1 post views Thread by Carl | last post: by
4 posts views Thread by bgold12 | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.