Use RGB_24BPP form for all images lacking alpha data.
This commit is contained in:
parent
ba95e0b07b
commit
a2fe30ff38
2 changed files with 44 additions and 29 deletions
|
@ -74,11 +74,13 @@ var ColorSpace = (function ColorSpaceClosure() {
|
|||
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,
|
||||
actualHeight, bpc, comps) {
|
||||
actualHeight, bpc, comps, alpha01) {
|
||||
var count = originalWidth * originalHeight;
|
||||
var rgbBuf = null;
|
||||
var numComponentColors = 1 << bpc;
|
||||
|
@ -108,14 +110,14 @@ var ColorSpace = (function ColorSpaceClosure() {
|
|||
/* alpha01 = */ 0);
|
||||
|
||||
if (!needsResizing) {
|
||||
// Fill in the RGB values directly into |rgbaBuf|.
|
||||
var rgbaPos = 0;
|
||||
// Fill in the RGB values directly into |dest|.
|
||||
var destPos = 0;
|
||||
for (var i = 0; i < count; ++i) {
|
||||
var key = comps[i] * 3;
|
||||
rgbaBuf[rgbaPos++] = colorMap[key];
|
||||
rgbaBuf[rgbaPos++] = colorMap[key + 1];
|
||||
rgbaBuf[rgbaPos++] = colorMap[key + 2];
|
||||
rgbaPos++;
|
||||
dest[destPos++] = colorMap[key];
|
||||
dest[destPos++] = colorMap[key + 1];
|
||||
dest[destPos++] = colorMap[key + 2];
|
||||
destPos += alpha01;
|
||||
}
|
||||
} else {
|
||||
rgbBuf = new Uint8Array(count * 3);
|
||||
|
@ -129,9 +131,9 @@ var ColorSpace = (function ColorSpaceClosure() {
|
|||
}
|
||||
} else {
|
||||
if (!needsResizing) {
|
||||
// Fill in the RGB values directly into |rgbaBuf|.
|
||||
this.getRgbBuffer(comps, 0, width * actualHeight, rgbaBuf, 0, bpc,
|
||||
/* alpha01 = */ 1);
|
||||
// Fill in the RGB values directly into |dest|.
|
||||
this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc,
|
||||
alpha01);
|
||||
} else {
|
||||
rgbBuf = new Uint8Array(count * 3);
|
||||
this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc,
|
||||
|
@ -145,11 +147,12 @@ var ColorSpace = (function ColorSpaceClosure() {
|
|||
originalHeight, width, height);
|
||||
}
|
||||
var rgbPos = 0;
|
||||
var actualLength = width * actualHeight * 4;
|
||||
for (var i = 0; i < actualLength; i += 4) {
|
||||
rgbaBuf[i] = rgbBuf[rgbPos++];
|
||||
rgbaBuf[i + 1] = rgbBuf[rgbPos++];
|
||||
rgbaBuf[i + 2] = rgbBuf[rgbPos++];
|
||||
var destPos = 0;
|
||||
for (var i = 0, ii = width * actualHeight; i < ii; i++) {
|
||||
dest[destPos++] = rgbBuf[rgbPos++];
|
||||
dest[destPos++] = rgbBuf[rgbPos++];
|
||||
dest[destPos++] = rgbBuf[rgbPos++];
|
||||
destPos += alpha01;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue