Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: byte[] to bufferedImage always NULL?

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question byte[] to bufferedImage always NULL?

    Hello all,
    I have an image stored in a text file as the following:
    27\F4\0E\39\C7\E2\33\D4\48\D2\88\CD\EE\04\57\3A\85 \0A\51\79\F1\6A\..........................

    I want to convert this string into bufferedImage
    I tried the following solution but it is working correctly
    String dcmPixelData =Files.toString(new File("./files/imagebytes.txt"), Charsets.ISO_8859_1) // I tried all possible charsets
    PixelDatabyte = dcmPixelData.getBytes(charset); // here also I tried all possible charset

    bufferedImage = ImageIO.read(new ByteArrayInputStream(PixelDatabyte ));

    But my bufferedImage variable is always NULL

    I tried other solutions but non of them is working for me
    Please help me if you have any ideas???
    Kind regards,
    Baraa


  2. #2
    Member suyog53's Avatar
    Join Date
    Sep 2012
    Location
    Mumbai
    Posts
    37
    My Mood
    Daring
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: byte[] to bufferedImage always NULL?

    Read your data of file into string'
    Split them when '\' occurs...ans store them serially in array..........'
    Then, put [0]--> Red, [1]-->Green, [2]-->Blue, [3]-->Red...and so on...'

Similar Threads

  1. Constructing 48 bit RGB bufferedimage
    By themadmathematician in forum AWT / Java Swing
    Replies: 2
    Last Post: March 20th, 2012, 02:49 PM
  2. drawing a BufferedImage onto a JPanel
    By nemo in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 13th, 2010, 07:48 PM
  3. Creating a bufferedimage!
    By Vexst in forum Java ME (Mobile Edition)
    Replies: 0
    Last Post: June 16th, 2010, 08:05 AM
  4. free memory of bufferedimage
    By mr_empty in forum Java SE APIs
    Replies: 2
    Last Post: January 19th, 2010, 06:14 AM
  5. Replies: 2
    Last Post: June 29th, 2009, 03:06 PM

Tags for this Thread