Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scrambled uint24 data #4188

Merged
merged 3 commits into from
Jul 17, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md).

### Fixed
- Fixed a bug where volume tracings could not be converted to hybrid. [#4159](https://github.com/scalableminds/webknossos/pull/4159)
- Fixed a bug where for uint24 color layers, scrambled data was shown for missing magnifications. [#4188](https://github.com/scalableminds/webknossos/pull/4188)
- Fixed a bug where collapsing/expanding all tree groups would trigger when toggling a single tree [#4178](https://github.com/scalableminds/webknossos/pull/4178)

### Removed
Expand Down
4 changes: 2 additions & 2 deletions frontend/javascripts/oxalis/api/api_latest.js
Original file line number Diff line number Diff line change
Expand Up @@ -866,8 +866,8 @@ class DataApi {
elementClass: ElementClass,
): $TypedArray {
const extent = V3.sub(bbox.max, bbox.min);
const TypedArrayClass = getConstructorForElementClass(elementClass);
const result = new TypedArrayClass(extent[0] * extent[1] * extent[2]);
const [TypedArrayClass, channelCount] = getConstructorForElementClass(elementClass);
const result = new TypedArrayClass(channelCount * extent[0] * extent[1] * extent[2]);
const bucketWidth = Constants.BUCKET_WIDTH;
buckets.reverse();

Expand Down
18 changes: 9 additions & 9 deletions frontend/javascripts/oxalis/model/bucket_data_handling/bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,18 @@ export const getConstructorForElementClass = (type: ElementClass) => {
switch (type) {
case "int8":
case "uint8":
return Uint8Array;
return [Uint8Array, 1];
case "int16":
case "uint16":
return Uint16Array;
return [Uint16Array, 1];
case "uint24":
// There is no Uint24Array and uint24 is treated in a special way (rgb) anyways
return Uint8Array;
return [Uint8Array, 3];
case "int32":
case "uint32":
return Uint32Array;
return [Uint32Array, 1];
case "float":
return Float32Array;
return [Float32Array, 1];
default:
throw new Error(`This type is not supported by the DataBucket class: ${type}`);
}
Expand Down Expand Up @@ -191,8 +191,8 @@ export class DataBucket {

getOrCreateData(): BucketDataArray {
if (this.data == null) {
const TypedArrayClass = getConstructorForElementClass(this.elementClass);
this.data = new TypedArrayClass(Constants.BUCKET_SIZE);
const [TypedArrayClass, channelCount] = getConstructorForElementClass(this.elementClass);
this.data = new TypedArrayClass(channelCount * Constants.BUCKET_SIZE);
if (!this.isMissing()) {
this.temporalBucketManager.addBucket(this);
}
Expand Down Expand Up @@ -225,15 +225,15 @@ export class DataBucket {
}

receiveData(arrayBuffer: ?Uint8Array): void {
const TypedArrayClass = getConstructorForElementClass(this.elementClass);
const [TypedArrayClass, channelCount] = getConstructorForElementClass(this.elementClass);
const data =
arrayBuffer != null
? new TypedArrayClass(
arrayBuffer.buffer,
arrayBuffer.byteOffset,
arrayBuffer.byteLength / TypedArrayClass.BYTES_PER_ELEMENT,
)
: new TypedArrayClass(Constants.BUCKET_SIZE);
: new TypedArrayClass(channelCount * Constants.BUCKET_SIZE);
switch (this.state) {
case BucketStateEnum.REQUESTED:
if (this.dirty) {
Expand Down