Hi Ringo,
The format of the byr file can be found in the avr/swing/JCapturePanel.java file. The format consists of a 4 byte color. The 4 bytes represent the Alpha Component, Red, Green, and Blue values of a color. The first four bytes in the file represents the pixel at x = 0, y = 0 in the image. The next four bytes represent the pixel at x = 0, y = 1 in the image. The image is 144 pixels high by 176 pixels wide. The following code segment is the Java code that creates the byr file:
- Code: Select all
ByteBuffer[] buffers = new ByteBuffer[bayerImage.getWidth()];
for(int x = 0; x < buffers.length; x++) {
buffers[x] = ByteBuffer.allocate(bayerImage.getHeight() * 4);
for(int y = 0; y < bayerImage.getHeight(); y++) {
buffers[x].putInt(bayerImage.getRGB(x, y));
}
buffers[x].flip();
}
To parse the byr file, I took advantage of how the Java New IO package reads files:
- Code: Select all
ByteBuffer[] buffers = new ByteBuffer[bayerImage.getWidth()];
for(int x = 0; x < buffers.length; x++) {
buffers[x] = ByteBuffer.allocate(bayerImage.getHeight() * 4);
}
inChannel.read(buffers);
If you have any more questions please let me know.
-- Bud