TWAIN Working Group

Newsletter Signup
Donate
Help keep TWAIN free
  • About TWAIN
    • What’s New?
    • News
    • Events
    • Membership
    • Consider a Donation
    • Contact Us
  • Why TWAIN?
  • Developers
    • Driver Developer
    • Application Developer
    • TWAIN Features
    • Specification & Tools
    • Self Certification Process
  • Support Forums
  • Scanner End-User
  • Find Certified Drivers
    • Facebook
    • LinkedIn
    • Vimeo

Reply To: 8-Bit image, memory transfer, algorithm problem

Forums › TWAIN Classic › 8-Bit image, memory transfer, algorithm problem › Reply To: 8-Bit image, memory transfer, algorithm problem

January 19, 2010 at 12:39 pm #25109
Billie
Participant
  • Topics - 2
  • Replies - 5
  • Total Posts - 7

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

Quick Links

Service Providers
TWAIN Support Forums
Membership
Contact Us
Privacy Policy

Newsletter Signup

TWAIN Working Group Family

TWAIN Working Group
TWAIN Direct®
TWAIN Resources
TWAIN Certified Drivers
PDF/raster

  • Facebook
  • GitHub
  • LinkedIn
  • Vimeo

Recent Topics

  • TWAIN for dental imaging integration
  • PDF/R For who and where?
  • Making searchable PDF with PDF/R
  • Backward compatibility with PDF/A and traditional PDF
  • could not open the twain source. Make sure there is a valid source for your sca
  • Quarterly Newsletter
  • TWAIN Working Group Membership
  • Logo Usage
  • TWAIN License
  • Contact Us
Privacy Policy • Privacy Tools • Copyright © 2021 TWAIN Working Group • by iHwy, LLC • Log in