Results 1 to 3 of 3
  1. #1
    nupurashi is offline Member
    Join Date
    Jan 2009
    Posts
    5
    Rep Power
    0

    Exclamation raw byte stream to image

    hello
    can any one suggest links and download material for image creation from raw byte stream from a accelograph

  2. #2
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    For raw byte data, I would create a MemoryImageSource, set it's pixels, and then pass it as the argument to createImage the Toolkit.

    suppose you had a byte array representing a 640x480 grayscale image (1 byte per pixel)

    Java Code:
    ....import statements
    
    byte[] bytes = ....however you're getting the data
    
    byte[] rgb = new byte[256];
    for(int i=0; i<rgb.length; i++)
      rgb[i] = (byte) i;
    
    IndexColorModel cm = new IndexColorModel(8,256,rgb,rgb,rgb);
    
    MemoryImageSource source = new MemoryImageSource(640,480,cm,bytes,0,480);
    
    Image newImage = Toolkit.getDefaultToolkit().createImage(source);
    Now you can do whatever you want with your image. Display it, persist it to a jpeg file, whatever. MemoryImageSource can be used to create animated Images as well, which sounds like what you might want.

  3. #3
    nupurashi is offline Member
    Join Date
    Jan 2009
    Posts
    5
    Rep Power
    0

    Default

    hello
    thanks 4 reply
    plz if u can mail me the simple code to do the same
    and i have the byte stream coming from a hardware device and the byte stream are as following


    0B01010101
    0B00000000
    0B00000000
    0B00000000
    0B00000000
    0B00000000
    0B00000000
    0B00000000
    0B00000000
    upto 65 times
    then again
    0B01010101
    again 65 readings
    when any change then
    0B00000100

    now to explain
    0B01010101 ------ marks starting of one frame
    we have 65 readings in a frame
    0B ---is header
    now each 0 stands for a section of frame
    0 stands for black and 1 stands for white

    now the problem is convert it into an image

    plz help me out

Similar Threads

  1. Receive uploaded image / video (byte array) from j2me on jsp.HOW???
    By angelicsign in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 06-29-2010, 06:21 PM
  2. image to byte code file conversion
    By nupurashi in forum New To Java
    Replies: 0
    Last Post: 01-28-2009, 10:25 AM
  3. [SOLVED] Image to byte[]
    By playwin2 in forum New To Java
    Replies: 25
    Last Post: 09-23-2008, 05:50 PM
  4. work on byte image in j2me
    By sunitikumar in forum CLDC and MIDP
    Replies: 0
    Last Post: 07-24-2008, 04:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •