-
Notifications
You must be signed in to change notification settings - Fork 209
Open
Description
Hello @constantinius,
I have run into a case where bitsPerSample seems to be an array. At first I thought this should not be allowed but after googling it, it appears to be fair play (http://www.fileformat.info/format/tiff/corion.htm).
--- BitsPerSample
Tag = 258 (102)
Type = word
N = SamplesPerPixel
Default = 1
Number of bits per sample. Note that this tag allows a different number of
bits per sample for each sample corresponding to a pixel. For example, RGB
color data could use a different number of bits per sample for each of the
three color planes.
I think without going overboard, we can just be clear that we only support the same bit-depth for each channel - then all we need to do is add a check for an Array here and then take the first value. We can even check to confirm they are all the same value and if not, just exit.
geotiff.js/src/geotiffimage.js
Lines 17 to 57 in 222ea10
| function arrayForType(format, bitsPerSample, size) { | |
| switch (format) { | |
| case 1: // unsigned integer data | |
| switch (bitsPerSample) { | |
| case 8: | |
| return new Uint8Array(size); | |
| case 16: | |
| return new Uint16Array(size); | |
| case 32: | |
| return new Uint32Array(size); | |
| default: | |
| break; | |
| } | |
| break; | |
| case 2: // twos complement signed integer data | |
| switch (bitsPerSample) { | |
| case 8: | |
| return new Int8Array(size); | |
| case 16: | |
| return new Int16Array(size); | |
| case 32: | |
| return new Int32Array(size); | |
| default: | |
| break; | |
| } | |
| break; | |
| case 3: // floating point data | |
| switch (bitsPerSample) { | |
| case 32: | |
| return new Float32Array(size); | |
| case 64: | |
| return new Float64Array(size); | |
| default: | |
| break; | |
| } | |
| break; | |
| default: | |
| break; | |
| } | |
| throw Error('Unsupported data format/bitsPerSample'); | |
| } |
Metadata
Metadata
Assignees
Labels
No labels