0

I could get the array of byte contains the YUV values and perform the same method in( Confusion on YUV NV21 conversion to RGB ) on it to get the array of int value represent RGB,and then i tried to convert this array to ByteBuffer so i can view it in JLabel. But what i can see is a separated vertical columns of Red, green, and Blue? Where is the wrong in my schema? Please help.

Community
  • 1
  • 1
java_87
  • 5
  • 6

1 Answers1

0

You need to create Image and set it's value by using your array , then display the image in Jlabel

Like this :

    byte[] imageInByte;////////////this byte array contain your RGB
    InputStream in = new ByteArrayInputStream(imageInByte);
    BufferedImage bImageFromConvert = ImageIO.read(in);

then You can display bImageFromConvert in JLabel

Like this :

 JLabel jLabel = new JLabel(new ImageIcon(bImageFromConvert ));
Alya'a Gamal
  • 5,624
  • 19
  • 34
  • before i edit my answer , x and y from for loop on the array which contain the RGB value – Alya'a Gamal Apr 24 '13 at 07:10
  • if i want to write it to file like this: try{ File outputfile = new File("saved.jpg"); ImageIO.write(bImageFromConvert, "jpg", outputfile); }catch(Exception e){ e.printStackTrace(); } i got an exception java.lang.IllegalArgumentException: im == null! – java_87 Apr 24 '13 at 07:17
  • actually i dont know ,i dont have any variable in this name – java_87 Apr 24 '13 at 07:20
  • Sure you have a one but you cant find it , check on this variable first ,in your exception you can find which line have the problem , or you can post the whole code to me – Alya'a Gamal Apr 24 '13 at 07:22
  • I find that the bImageFromConvert is null which cause this exception to appear when im trying to write to file – java_87 Apr 24 '13 at 07:25
  • you should but your byte array in `bImageFromConvert` before you write it , so if the image is null may be your byte array is empty check it again – Alya'a Gamal Apr 24 '13 at 07:27