Cleaner putBinaryImageData
This commit is contained in:
parent
f70a072cde
commit
83cd530f45
@ -512,24 +512,33 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
} else if (imgData.kind === ImageKind.RGBA_32BPP) {
|
||||
// RGBA, 32-bits per pixel.
|
||||
|
||||
for (i = 0; i < totalChunks; i++) {
|
||||
thisChunkHeight =
|
||||
(i < fullChunks) ? fullChunkHeight : partialChunkHeight;
|
||||
elemsInThisChunk = imgData.width * thisChunkHeight * 4;
|
||||
|
||||
j = 0;
|
||||
elemsInThisChunk = width * fullChunkHeight * 4;
|
||||
for (i = 0; i < fullChunks; i++) {
|
||||
dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
|
||||
srcPos += elemsInThisChunk;
|
||||
|
||||
ctx.putImageData(chunkImgData, 0, i * fullChunkHeight);
|
||||
ctx.putImageData(chunkImgData, 0, j);
|
||||
j += fullChunkHeight;
|
||||
}
|
||||
if (i < totalChunks) {
|
||||
elemsInThisChunk = width * partialChunkHeight * 4;
|
||||
dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
|
||||
ctx.putImageData(chunkImgData, 0, j);
|
||||
}
|
||||
|
||||
} else if (imgData.kind === ImageKind.RGB_24BPP) {
|
||||
// RGB, 24-bits per pixel.
|
||||
thisChunkHeight = fullChunkHeight;
|
||||
elemsInThisChunk = width * thisChunkHeight;
|
||||
for (i = 0; i < totalChunks; i++) {
|
||||
thisChunkHeight =
|
||||
(i < fullChunks) ? fullChunkHeight : partialChunkHeight;
|
||||
elemsInThisChunk = imgData.width * thisChunkHeight * 3;
|
||||
if (i >= fullChunks) {
|
||||
thisChunkHeight =partialChunkHeight;
|
||||
elemsInThisChunk = width * thisChunkHeight;
|
||||
}
|
||||
|
||||
destPos = 0;
|
||||
for (j = 0; j < elemsInThisChunk; j += 3) {
|
||||
for (j = elemsInThisChunk; j--;) {
|
||||
dest[destPos++] = src[srcPos++];
|
||||
dest[destPos++] = src[srcPos++];
|
||||
dest[destPos++] = src[srcPos++];
|
||||
|
Loading…
x
Reference in New Issue
Block a user