Forums › TWAIN Classic › 8-Bit image, memory transfer, algorithm problem › Reply To: 8-Bit image, memory transfer, algorithm problem
Yes, native mode works fine – but I need the memory transfer.
So why is there a difference between the Columns and BytesPerRow? The Image has a Resolution of 850 x 1100 Pixels. For 8-Bit grayscale image there would only be need for 850 bytes per row?
Saveing the File as BMP (in memory mode) has the same effect, but the File-Format doesn’t matter at this point. A have a BufferedImage with 850 x 1100 Pixels and set every Pixel explicitly:
bfImage.setRGB(x, y, (rgb[0] & 0xff) << 16
| (rgb[1] & 0xff) << 8
| (rgb[2] & 0xff));
So x, y is in fact the x- and y-Position of the Pixel in the Image. My memory buffer is a java.nio.ByteBuffer which is allocates with the preferred size of bytes:
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(bufferSizes.getPreferred());
So after every DG_IMAGE, DAT_IMAGEMEMXFER, MSG_GET Triplet, the bytes are written to the byteBuffer.
The byteBuffer.get() Method reads 1 byte from the buffer’s current position. The position begins with 0 (clear() method) and is incremented with every get() call.
So at the moment I only read 850 bytes (columns=850) from the buffer per row and do not care about the 2 bytes still … Oops…
Fixed it! I have to increment the buffer position by 2 after every row, now I have a nice Picture!
So it is O.K. not careing about the 2 extra bytes in every row?
Thanks for your Help!!!
Billie