Access to <img> pixels

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim Streater

    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?
  • Bjoern Hoehrmann

    #2
    Re: Access to &lt;img&gt; pixels

    * Tim Streater wrote in comp.lang.javas cript:
    >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,

    does just that.
    --
    Björn Höhrmann · mailto:bjoern@h oehrmann.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/

    Comment

    • Tim Streater

      #3
      Re: Access to &lt;img&gt; pixels

      In article
      <1k1o34tl0men0o v9o4d0q6g4k6lk9 tfcv7@hive.bjoe rn.hoehrmann.de >,
      Bjoern Hoehrmann <bjoern@hoehrma nn.dewrote:
      * Tim Streater wrote in comp.lang.javas cript:
      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,

      does just that.
      Now this, might be just what the doctor ordered.

      Thanks - I shall give that scheme a try!

      Comment

      • VK

        #4
        Re: Access to &lt;img&gt; pixels

        On May 27, 5:13 pm, Tim Streater <tim.strea...@d ante.org.ukwrot e:
        In article
        <1k1o34tl0men0o v9o4d0q6g4k6lk9 tf...@hive.bjoe rn.hoehrmann.de >,
        Bjoern Hoehrmann <bjo...@hoehrma nn.dewrote:
        >
        >
        >
        * Tim Streater wrote in comp.lang.javas cript:
        >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,

        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.

        Comment

        • Tim Streater

          #5
          Re: Access to &lt;img&gt; pixels

          In article
          <c9b69aa3-9da3-4062-bf45-fd71841e9138@r6 6g2000hsg.googl egroups.com>,
          VK <schools_ring@y ahoo.comwrote:
          On May 27, 5:13 pm, Tim Streater <tim.strea...@d ante.org.ukwrot e:
          In article
          <1k1o34tl0men0o v9o4d0q6g4k6lk9 tf...@hive.bjoe rn.hoehrmann.de >,
          Bjoern Hoehrmann <bjo...@hoehrma nn.dewrote:


          * Tim Streater wrote in comp.lang.javas cript:
          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.

          Comment

          • david.karr

            #6
            Re: Access to &lt;img&gt; pixels

            On May 27, 6:00 am, Tim Streater <tim.strea...@d ante.org.ukwrot e:
            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.

            Comment

            Working...