drawing in javascript

Discussion in 'HTML' started by David Landy, Oct 13, 2003.

  1. David Landy

    David Landy Guest

    how can i create an inline color image in javascript? the code snippet
    below (which was posted on this group in 2000) shows how to do a
    single-bit image -- how can this be extended to eg 8-bit color depth?

    thanks for any help you can give.

    david

    > <script language="javascript">
    > <!--
    > var trash = "#define a_width 16\n#define a_height 16\nstatic "+
    > "char a_bits[] = {0x00,0x01,0xe0,0x0f,0x10,0x10,0xf8,0x3f,"+
    > "0x10,0x10,0x50,0x15,0x50,0x15,0x50,0x15,0x50,0x15,"+
    > "0x50,0x15,0x50,0x15,0x50,0x15,0x50,0x15,0x10,0x10,"+
    > "0xe0,0x0f,0x00,0x00};";
    > // -->
    > </script>
    > </head>
    > <body>
    > <img src="javascript:trash" alt="">
    > ...it's just a small trashcan .
    > </body>
    >
    > chan555
    >
    >
     
    David Landy, Oct 13, 2003
    #1
    1. Advertising

  2. David Landy wrote:

    > how can i create an inline color image in javascript?


    What browsers is it important for this to work in? If IE isn't important,
    perhaps the "data:" URL scheme might be your friend. For example:

    <a href="data:text/plain,Hello%20World">greeting</a>

    See http://www.ietf.org/rfc/rfc2397.txt for more details.

    If this on its own isn't an option (for example, IE support is required),
    it is probably possible to use the above scheme and then use some
    JavaScript to decode the "data:" URL and display it in Internet Explorer.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me - http://www.goddamn.co.uk/tobyink/?id=132
     
    Toby A Inkster, Oct 13, 2003
    #2
    1. Advertising

  3. David Landy

    David Landy Guest

    Many thanks Toby.

    Sadly IE is my main target audience ;-)

    Any idea how to decode the data: and turn it into an image source?

    David.

    Toby A Inkster <> wrote in message news:<>...
    > David Landy wrote:
    >
    > > how can i create an inline color image in javascript?

    >
    > What browsers is it important for this to work in? If IE isn't important,
    > perhaps the "data:" URL scheme might be your friend. For example:
    >
    > <a href="data:text/plain,Hello%20World">greeting</a>
    >
    > See http://www.ietf.org/rfc/rfc2397.txt for more details.
    >
    > If this on its own isn't an option (for example, IE support is required),
    > it is probably possible to use the above scheme and then use some
    > JavaScript to decode the "data:" URL and display it in Internet Explorer.
     
    David Landy, Oct 15, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    676
    Kevin Spencer
    Jan 9, 2006
  2. defn noob
    Replies:
    1
    Views:
    420
    Mark Space
    Jun 28, 2008
  3. Stefan Burger

    drawing vector lines with javascript

    Stefan Burger, Jun 26, 2003, in forum: Javascript
    Replies:
    8
    Views:
    237
    cwdjr
    Jun 27, 2003
  4. Replies:
    9
    Views:
    146
    cwdjrxyz
    Jun 13, 2006
  5. javelin
    Replies:
    17
    Views:
    583
    Tom Cole
    Jun 6, 2008
Loading...

Share This Page