Skip to content

Commit

Permalink
Merge branch 'Jimbly-fix-offsets'
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlapp committed Jul 21, 2019
2 parents 9da7a84 + 1b35d64 commit 1a9a0a9
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/gifcodec.js
Expand Up @@ -114,8 +114,24 @@ class GifCodec
let info, buffer;
try {
info = reader.frameInfo(frameIndex);
buffer = new Buffer(info.width * info.height * 4);
buffer = new Buffer(reader.width * reader.height * 4);
reader.decodeAndBlitFrameRGBA(frameIndex, buffer);
if (info.width !== reader.width || info.height !== reader.height) {
if (info.y) {
// skip unused rows
buffer = buffer.slice(info.y * reader.width * 4);
}
if (reader.width > info.width) {
// skip scanstride
for (let ii = 0; ii < info.height; ++ii) {
buffer.copy(buffer, ii * info.width * 4,
(info.x + ii * reader.width) * 4,
(info.x + ii * reader.width) * 4 + info.width * 4);
}
}
// trim buffer to size
buffer = buffer.slice(0, info.width * info.height * 4);
}
}
catch (err) {
throw new GifError(err);
Expand Down

0 comments on commit 1a9a0a9

Please sign in to comment.