Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions lib/decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ export default class BmpDecoder implements IImage {

this.width = this.readUInt32LE();
this.height = this.readUInt32LE();
// negative value are possible here => implies bottom down
this.height =
this.height > 0x7fffffff ? this.height - 0x100000000 : this.height;

this.planes = this.buffer.readUInt16LE(this.pos);
this.pos += 2;
Expand Down
7 changes: 7 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ export default {
new BmpDecoder(bmpData, options),
encode: (imgData: IImage) => new BmpEncoder(imgData)
};

export function decode(bmpData: Buffer, options?: IDecoderOptions) {
return new BmpDecoder(bmpData, options);
}
export function encode(imgData: IImage) {
return new BmpEncoder(imgData);
}