diff --git a/lib/decoder.ts b/lib/decoder.ts index e5344d4..cf3733d 100644 --- a/lib/decoder.ts +++ b/lib/decoder.ts @@ -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; diff --git a/lib/index.ts b/lib/index.ts index 2c7f6e0..e58c561 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -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); +}