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) {
|
} else if (imgData.kind === ImageKind.RGBA_32BPP) {
|
||||||
// RGBA, 32-bits per pixel.
|
// RGBA, 32-bits per pixel.
|
||||||
|
|
||||||
for (i = 0; i < totalChunks; i++) {
|
j = 0;
|
||||||
thisChunkHeight =
|
elemsInThisChunk = width * fullChunkHeight * 4;
|
||||||
(i < fullChunks) ? fullChunkHeight : partialChunkHeight;
|
for (i = 0; i < fullChunks; i++) {
|
||||||
elemsInThisChunk = imgData.width * thisChunkHeight * 4;
|
|
||||||
|
|
||||||
dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
|
dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
|
||||||
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) {
|
} else if (imgData.kind === ImageKind.RGB_24BPP) {
|
||||||
// RGB, 24-bits per pixel.
|
// RGB, 24-bits per pixel.
|
||||||
|
thisChunkHeight = fullChunkHeight;
|
||||||
|
elemsInThisChunk = width * thisChunkHeight;
|
||||||
for (i = 0; i < totalChunks; i++) {
|
for (i = 0; i < totalChunks; i++) {
|
||||||
thisChunkHeight =
|
if (i >= fullChunks) {
|
||||||
(i < fullChunks) ? fullChunkHeight : partialChunkHeight;
|
thisChunkHeight =partialChunkHeight;
|
||||||
elemsInThisChunk = imgData.width * thisChunkHeight * 3;
|
elemsInThisChunk = width * thisChunkHeight;
|
||||||
|
}
|
||||||
|
|
||||||
destPos = 0;
|
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++];
|
dest[destPos++] = src[srcPos++];
|
||||||
dest[destPos++] = src[srcPos++];
|
dest[destPos++] = src[srcPos++];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user