Skip to content

Commit

Permalink
Fix incorrect condition in DibReader.alphaMask getter
Browse files Browse the repository at this point in the history
  • Loading branch information
Cirras committed Jul 28, 2023
1 parent 6bdd8c1 commit e5f0184
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/core/gfx/load/dib-reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export class DIBReader {
return ((this.width * this.depth + 31) & ~31) >> 3;
}

get hasBitMasks() {
get hasRgbBitMasks() {
switch (this.headerType) {
case HeaderType.Core:
case HeaderType.Core2:
Expand All @@ -254,32 +254,45 @@ export class DIBReader {
}
}

get hasAlphaBitMask() {
switch (this.headerType) {
case HeaderType.Core:
case HeaderType.Core2:
case HeaderType.V2:
return false;
case HeaderType.Info:
return this.compression === Compression.AlphaBitfields;
default:
return true;
}
}

get redMask() {
if (!this.hasBitMasks) {
if (!this.hasRgbBitMasks) {
return 0;
} else {
return this.readUint32(40);
}
}

get greenMask() {
if (!this.hasBitMasks) {
if (!this.hasRgbBitMasks) {
return 0;
} else {
return this.readUint32(44);
}
}

get blueMask() {
if (!this.hasBitMasks) {
if (!this.hasRgbBitMasks) {
return 0;
} else {
return this.readUint32(48);
}
}

get alphaMask() {
if (!this.hasBitMasks || this.headerType === HeaderType.V2) {
if (!this.hasAlphaBitMask) {
return 0;
} else {
return this.readUint32(52);
Expand Down

0 comments on commit e5f0184

Please sign in to comment.