byte[] data = super.getData();
// bitmap file-header, corresponds to a
// Windows BITMAPFILEHEADER structure
// (For more information, consult the Windows API Programmer's reference )
byte[] header = new byte[HEADER_SIZE];
//Specifies the file type. It must be set to the signature word BM (0x4D42) to indicate bitmap.
LittleEndian.putInt(header, 0, 0x4D42);
//Specifies the size, in bytes, of the bitmap file.
LittleEndian.putInt(header, 2, data.length); //DIB length including the header
//Reserved; set to zero
LittleEndian.putInt(header, 6, 0);
//the offset, in bytes, from the header to the bitmap bits (looks like it is always 2)
LittleEndian.putInt(header, 10, 2);
//DIB data is the header + dib bytes
byte[] dib = new byte[header.length + data.length];
System.arraycopy(header, 0, dib, 0, header.length);
System.arraycopy(data, 0, dib, header.length, data.length);
return dib;