Skip to content

16 bit Depth Image #766

Answered by axxel
Kris523 asked this question in Q&A
Discussion options

You must be logged in to vote

You are right: 16bit images are not (directly) supported. There is nothing to worry about with respect to lost fidelity. I highly recommend you convert your 16 bit images outside of zxing-cpp into an 8bit image and use that.

That said, you can setup an ImageView object that treats your 16bit data as 8bit data:

const uint16_t* data; // greyscale 16 bit image data
int w, h;
auto iv = ImageView(reinterpret_cast<const uint8_t*>(data), w, h, ImageFormat::Lum, 2 * w, 2);

The last 2 is the pixel stride, i.e. how many bytes need to be moved forward to get to the next pixel. You need to change the above code if you are not on an Intel architecture (byte order).

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by axxel
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #761 on April 16, 2024 12:01.