Skip to content

Commit

Permalink
feat(blp): add helper to return all images from a BLP
Browse files Browse the repository at this point in the history
  • Loading branch information
fallenoak committed Dec 22, 2023
1 parent 740c965 commit 227b0da
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/lib/blp/Blp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,25 @@ class Blp {
}
}

getImages(
startLevel: number = 0,
outputFormat: BLP_IMAGE_FORMAT = BLP_IMAGE_FORMAT.IMAGE_UNSPECIFIED,
): BlpImage[] {
if (startLevel > this.#images.length - 1) {
throw new Error(
`Requested start level out of range: ${startLevel} > ${this.#images.length - 1}`,
);
}

const images: BlpImage[] = [];

for (let level = startLevel; level < this.#images.length; level++) {
images.push(this.getImage(level, outputFormat));
}

return images;
}

/**
* For a given mip level, return a BlpImage containing the unconverted image data from the Blp. If the Blp uses a
* palette, the image data will be converted to IMAGE_FORMAT.IMAGE_ABGR8888 before being returned.
Expand Down

0 comments on commit 227b0da

Please sign in to comment.