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. Advertisements

  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. Advertisements

  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. Advertisements

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. Sergio Dinis

    How to Serialize System.Drawing.Pen

    Sergio Dinis, Oct 2, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    2,854
    Jay B. Harlow [MVP - Outlook]
    Oct 3, 2003
  2. ham Come>

    How to save a Drawing?

    ham Come>, Nov 10, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    577
    Herfried K. Wagner [MVP]
    Nov 10, 2004
  3. krby_xtrm

    tool for drawing timing diagrams

    krby_xtrm, Nov 20, 2005, in forum: VHDL
    Replies:
    7
    Views:
    8,888
    diamondstud
    Jan 23, 2009
  4. Replies:
    1
    Views:
    877
    Kevin Spencer
    Jan 9, 2006
  5. defn noob
    Replies:
    1
    Views:
    615
    Mark Space
    Jun 28, 2008
  6. Stefan Burger

    drawing vector lines with javascript

    Stefan Burger, Jun 26, 2003, in forum: Javascript
    Replies:
    8
    Views:
    443
    cwdjr
    Jun 27, 2003
  7. Replies:
    9
    Views:
    354
    cwdjrxyz
    Jun 13, 2006
  8. javelin
    Replies:
    17
    Views:
    771
    Tom Cole
    Jun 6, 2008
Loading...