Drawing a 640x480 Ras Image

Discussion in 'Python' started by W. Watson, Sep 21, 2007.

  1. W. Watson

    W. Watson Guest

    I'm getting a 640x480 greyscale image from a video device. I'd like to place
    it on a canvas and then draw on the image. Does PIL or some image facility
    allow me to do that?

    --
    Wayne Watson (Nevada City, CA)

    Web Page: <speckledwithStars.net>
    W. Watson, Sep 21, 2007
    #1
    1. Advertising

  2. W. Watson

    W. Watson Guest

    Re: Drawing a 640x480 Raw Image

    Corrected misspelling in Subject. The image here is nothing more than a
    640x480 byte array. Each byte is a gra[e]yscale value.

    W. Watson wrote:
    > I'm getting a 640x480 greyscale image from a video device. I'd like to
    > place it on a canvas and then draw on the image. Does PIL or some image
    > facility allow me to do that?
    >


    --
    Wayne Watson (Nevada City, CA)

    Web Page: <speckledwithStars.net>
    W. Watson, Sep 21, 2007
    #2
    1. Advertising

  3. Re: Drawing a 640x480 Raw Image

    On Thu, 20 Sep 2007 20:49:59 -0700, W. Watson wrote:

    > W. Watson wrote:
    >> I'm getting a 640x480 greyscale image from a video device. I'd like to
    >> place it on a canvas and then draw on the image. Does PIL or some image
    >> facility allow me to do that?

    >
    > Corrected misspelling in Subject. The image here is nothing more than a
    > 640x480 byte array. Each byte is a gra[e]yscale value.


    PIL can do this:

    from PIL import Image

    def main():
    width = 640
    height = 480
    image = Image.new('L', (width, height))
    data = [x * y % 256 for x in xrange(width) for y in xrange(height)]
    image.putdata(data)
    image.save('test.png')

    `data` can be any iterable with byte values.

    Ciao,
    Marc 'BlackJack' Rintsch
    Marc 'BlackJack' Rintsch, Sep 21, 2007
    #3
  4. W. Watson

    W. Watson Guest

    Re: Drawing a 640x480 Raw Image

    Very good. I'll give it a try.

    Marc 'BlackJack' Rintsch wrote:
    > On Thu, 20 Sep 2007 20:49:59 -0700, W. Watson wrote:
    >
    >> W. Watson wrote:
    >>> I'm getting a 640x480 greyscale image from a video device. I'd like to
    >>> place it on a canvas and then draw on the image. Does PIL or some image
    >>> facility allow me to do that?

    >> Corrected misspelling in Subject. The image here is nothing more than a
    >> 640x480 byte array. Each byte is a gra[e]yscale value.

    >
    > PIL can do this:
    >
    > from PIL import Image
    >
    > def main():
    > width = 640
    > height = 480
    > image = Image.new('L', (width, height))
    > data = [x * y % 256 for x in xrange(width) for y in xrange(height)]
    > image.putdata(data)
    > image.save('test.png')
    >
    > `data` can be any iterable with byte values.
    >
    > Ciao,
    > Marc 'BlackJack' Rintsch


    --
    Wayne Watson (Nevada City, CA)

    Web Page: <speckledwithStars.net>
    W. Watson, Sep 21, 2007
    #4
  5. W. Watson

    W. Watson Guest

    Re: Drawing a 640x480 Raw Image

    Oops. What I think I'm looking for is a way to open a data file of records
    that are 640x480 that are gray scaled. I probably need something like an
    open and a read. Once I've got that, then I need to place the raw image into
    a draw area on the canvas, so that I can draw on the image.

    W. Watson wrote:
    > Very good. I'll give it a try.
    >
    > Marc 'BlackJack' Rintsch wrote:
    >> On Thu, 20 Sep 2007 20:49:59 -0700, W. Watson wrote:
    >>
    >>> W. Watson wrote:
    >>>> I'm getting a 640x480 greyscale image from a video device. I'd like
    >>>> to place it on a canvas and then draw on the image. Does PIL or some
    >>>> image facility allow me to do that?
    >>> Corrected misspelling in Subject. The image here is nothing more than
    >>> a 640x480 byte array. Each byte is a gra[e]yscale value.

    >>
    >> PIL can do this:
    >>
    >> from PIL import Image
    >>
    >> def main():
    >> width = 640
    >> height = 480
    >> image = Image.new('L', (width, height))
    >> data = [x * y % 256 for x in xrange(width) for y in xrange(height)]
    >> image.putdata(data)
    >> image.save('test.png')
    >>
    >> `data` can be any iterable with byte values.
    >>
    >> Ciao,
    >> Marc 'BlackJack' Rintsch

    >


    --
    Wayne Watson (Nevada City, CA)

    Web Page: <speckledwithStars.net>
    W. Watson, Sep 21, 2007
    #5
    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. Fred Armitage

    RAS Api

    Fred Armitage, Jul 7, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,680
    Fred Armitage
    Jul 7, 2003
  2. iyappan

    RAS Component

    iyappan, Aug 5, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    414
    iyappan
    Aug 5, 2003
  3. =?Utf-8?B?Q2hyaXMgUG9kbW9yZQ==?=

    Optimising pages for 640x480 or 800x600

    =?Utf-8?B?Q2hyaXMgUG9kbW9yZQ==?=, Dec 10, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    342
    =?Utf-8?B?Q2hyaXMgUG9kbW9yZQ==?=
    Dec 10, 2004
  4. Guenter
    Replies:
    10
    Views:
    728
    Michael Sparks
    Sep 9, 2005
  5. W. eWatson
    Replies:
    0
    Views:
    199
    W. eWatson
    Apr 1, 2009
Loading...

Share This Page