Skip to content

Commit

Permalink
exit early
Browse files Browse the repository at this point in the history
  • Loading branch information
hipstersmoothie committed Sep 1, 2018
1 parent 586602c commit c80b4bb
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/core/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -741,20 +741,18 @@ class Jimp extends EventEmitter {
* @return {boolean} hasAlpha whether the image contains opaque pixels
*/
hasAlpha() {
let hasAlpha = false;

for (let yIndex = 0; yIndex < this.bitmap.height && !hasAlpha; yIndex++) {
for (let xIndex = 0; xIndex < this.bitmap.width && !hasAlpha; xIndex++) {
for (let yIndex = 0; yIndex < this.bitmap.height; yIndex++) {
for (let xIndex = 0; xIndex < this.bitmap.width; xIndex++) {
const idx = (this.bitmap.width * yIndex + xIndex) << 2;
const alpha = this.bitmap.data[idx + 3];

if (alpha !== 0xff) {
hasAlpha = true;
return true;
}
}
}

return hasAlpha;
return false;
}
}

Expand Down

0 comments on commit c80b4bb

Please sign in to comment.