Hi, i am having a bitmap image sent to me over tcp, then stores the data in a byte[] array called jacketBytes, but thenen when i try to make an image out of it using;
BufferedImage img = ImageIO.read(new ByteArrayInputStream(bytes));
i get Nullpointerexception
so i started troubleshooting by writing out my byte array in different ways.
FileOutputStream fos = new FileOutputStream(strFilePath);
System.out.println("total bytes: "+bytes.length);
for(int i =0; i < 56; i++){
System.out.print("0x"+bytes[i]+" ");
}
System.out.println();
for(int i =0; i < 1000; i++){
System.out.print((char)bytes[i]);
}
System.out.println();
bytes.toString();
System.out.println(bytes.toString());
fos.write(bytes);
fos.close();
the output i get from that is :
total bytes: 34928
0x52 0x50 0x52 0x68 0x51 0x54 0x48 0x52 0x48 0x49 0x48 0x48 0x48 0x48 0x48 0x48 0x48 0x48 0x48 0x48
424D3604010000000000
the first part 42 4D(0x52 0x50 0x52 0x68) is BM in ASCII just the way a bmp header is supposed to start.
what i cant figure out is what the rest if the data is! there is supposed to be 4 bytes containing the image data in bytes.
at least according to wikipedia
wikipedia
The only documentation on how the data is sent to me is this:
NET/USB Jacket Art/Album Art Data
t-> Image type 0:BMP,1:JPEG
p-> Packet flag 0:Start, 1:Next, 2:End
xxxxxxxxxxxxxx -> Jacket/Album Art Data (valiable length, 1024 ASCII HEX letters max)
i manage to store it in a single byte Array but i do not know how to make it in to image data since it contains so much nulls!
Help appreciated!