|
|
@ -74,11 +74,13 @@ var ColorSpace = (function ColorSpaceClosure() { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
}, |
|
|
|
}, |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Fills in the RGB colors in an RGBA buffer. |
|
|
|
* Fills in the RGB colors in the destination buffer. alpha01 indicates |
|
|
|
|
|
|
|
* how many alpha components there are in the dest array; it will be either |
|
|
|
|
|
|
|
* 0 (RGB array) or 1 (RGBA array). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fillRgb: function ColorSpace_fillRgb(rgbaBuf, originalWidth, |
|
|
|
fillRgb: function ColorSpace_fillRgb(dest, originalWidth, |
|
|
|
originalHeight, width, height, |
|
|
|
originalHeight, width, height, |
|
|
|
actualHeight, bpc, comps) { |
|
|
|
actualHeight, bpc, comps, alpha01) { |
|
|
|
var count = originalWidth * originalHeight; |
|
|
|
var count = originalWidth * originalHeight; |
|
|
|
var rgbBuf = null; |
|
|
|
var rgbBuf = null; |
|
|
|
var numComponentColors = 1 << bpc; |
|
|
|
var numComponentColors = 1 << bpc; |
|
|
@ -108,14 +110,14 @@ var ColorSpace = (function ColorSpaceClosure() { |
|
|
|
/* alpha01 = */ 0); |
|
|
|
/* alpha01 = */ 0); |
|
|
|
|
|
|
|
|
|
|
|
if (!needsResizing) { |
|
|
|
if (!needsResizing) { |
|
|
|
// Fill in the RGB values directly into |rgbaBuf|.
|
|
|
|
// Fill in the RGB values directly into |dest|.
|
|
|
|
var rgbaPos = 0; |
|
|
|
var destPos = 0; |
|
|
|
for (var i = 0; i < count; ++i) { |
|
|
|
for (var i = 0; i < count; ++i) { |
|
|
|
var key = comps[i] * 3; |
|
|
|
var key = comps[i] * 3; |
|
|
|
rgbaBuf[rgbaPos++] = colorMap[key]; |
|
|
|
dest[destPos++] = colorMap[key]; |
|
|
|
rgbaBuf[rgbaPos++] = colorMap[key + 1]; |
|
|
|
dest[destPos++] = colorMap[key + 1]; |
|
|
|
rgbaBuf[rgbaPos++] = colorMap[key + 2]; |
|
|
|
dest[destPos++] = colorMap[key + 2]; |
|
|
|
rgbaPos++; |
|
|
|
destPos += alpha01; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
rgbBuf = new Uint8Array(count * 3); |
|
|
|
rgbBuf = new Uint8Array(count * 3); |
|
|
@ -129,9 +131,9 @@ var ColorSpace = (function ColorSpaceClosure() { |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (!needsResizing) { |
|
|
|
if (!needsResizing) { |
|
|
|
// Fill in the RGB values directly into |rgbaBuf|.
|
|
|
|
// Fill in the RGB values directly into |dest|.
|
|
|
|
this.getRgbBuffer(comps, 0, width * actualHeight, rgbaBuf, 0, bpc, |
|
|
|
this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, |
|
|
|
/* alpha01 = */ 1); |
|
|
|
alpha01); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
rgbBuf = new Uint8Array(count * 3); |
|
|
|
rgbBuf = new Uint8Array(count * 3); |
|
|
|
this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, |
|
|
|
this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, |
|
|
@ -145,11 +147,12 @@ var ColorSpace = (function ColorSpaceClosure() { |
|
|
|
originalHeight, width, height); |
|
|
|
originalHeight, width, height); |
|
|
|
} |
|
|
|
} |
|
|
|
var rgbPos = 0; |
|
|
|
var rgbPos = 0; |
|
|
|
var actualLength = width * actualHeight * 4; |
|
|
|
var destPos = 0; |
|
|
|
for (var i = 0; i < actualLength; i += 4) { |
|
|
|
for (var i = 0, ii = width * actualHeight; i < ii; i++) { |
|
|
|
rgbaBuf[i] = rgbBuf[rgbPos++]; |
|
|
|
dest[destPos++] = rgbBuf[rgbPos++]; |
|
|
|
rgbaBuf[i + 1] = rgbBuf[rgbPos++]; |
|
|
|
dest[destPos++] = rgbBuf[rgbPos++]; |
|
|
|
rgbaBuf[i + 2] = rgbBuf[rgbPos++]; |
|
|
|
dest[destPos++] = rgbBuf[rgbPos++]; |
|
|
|
|
|
|
|
destPos += alpha01; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|