aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormeltingice <meltingice8917@gmail.com>2012-04-19 21:58:20 -0400
committermeltingice <meltingice8917@gmail.com>2012-04-19 21:58:20 -0400
commit6c1e32de3067fd2ab29a351ca8d9ad6febadf81f (patch)
treef4c2420c5f205796b06268e12516a57232b4588d
parentAdded support for more 16-bit color modes (diff)
downloadpsd.js-6c1e32de3067fd2ab29a351ca8d9ad6febadf81f.tar.xz
psd.js-6c1e32de3067fd2ab29a351ca8d9ad6febadf81f.zip
Added support for LAB 16-bit color
-rw-r--r--examples/images/test-lab16.psdbin0 -> 1971872 bytes
-rw-r--r--lib/psd.js21
-rw-r--r--lib/psd.min.js2
-rwxr-xr-xsrc/psdimage.coffee17
4 files changed, 40 insertions, 0 deletions
diff --git a/examples/images/test-lab16.psd b/examples/images/test-lab16.psd
new file mode 100644
index 0000000..53b5b12
--- /dev/null
+++ b/examples/images/test-lab16.psd
Binary files differ
diff --git a/lib/psd.js b/lib/psd.js
index b22353b..0fe2e01 100644
--- a/lib/psd.js
+++ b/lib/psd.js
@@ -1588,6 +1588,27 @@ var jspack = new JSPack(); ;
return _results;
};
+ PSDImage.prototype.combineLAB16Channel = function() {
+ var a, alpha, b, i, l, rgb, _i, _ref, _results;
+ _results = [];
+ for (i = _i = 0, _ref = this.numPixels; _i < _ref; i = _i += 2) {
+ if (this.getImageChannels() === 4) {
+ alpha = this.channelData[i];
+ l = this.channelData[i + this.channelLength];
+ a = this.channelData[i + this.channelLength * 2];
+ b = this.channelData[i + this.channelLength * 3];
+ } else {
+ alpha = 255;
+ l = this.channelData[i];
+ a = this.channelData[i + this.channelLength];
+ b = this.channelData[i + this.channelLength * 2];
+ }
+ rgb = PSDColor.labToRGB(l * 100 >> 8, a - 128, b - 128);
+ _results.push(this.pixelData.push(rgb.r, rgb.g, rgb.b, this.getAlphaValue(alpha)));
+ }
+ return _results;
+ };
+
PSDImage.prototype.combineMultiChannel8 = function() {
var c, i, k, m, rgb, y, _i, _ref, _results;
_results = [];
diff --git a/lib/psd.min.js b/lib/psd.min.js
index 650c6a1..dd1d37e 100644
--- a/lib/psd.min.js
+++ b/lib/psd.min.js
@@ -176,6 +176,8 @@ return _results;};PSDImage.prototype.combineCMYK16Channel=function(){var a,c,i,k
rgb=PSDColor.cmykToRGB(255-c,255-m,255-y,255-k);_results.push(this.pixelData.push(rgb.r,rgb.g,rgb.b,this.getAlphaValue(a)));}
return _results;};PSDImage.prototype.combineLAB8Channel=function(){var a,alpha,b,i,l,rgb,_i,_ref,_results;_results=[];for(i=_i=0,_ref=this.numPixels;0<=_ref?_i<_ref:_i>_ref;i=0<=_ref?++_i:--_i){if(this.getImageChannels()===4){alpha=this.channelData[i];l=this.channelData[i+this.channelLength];a=this.channelData[i+this.channelLength*2];b=this.channelData[i+this.channelLength*3];}else{alpha=255;l=this.channelData[i];a=this.channelData[i+this.channelLength];b=this.channelData[i+this.channelLength*2];}
rgb=PSDColor.labToRGB(l*100>>8,a-128,b-128);_results.push(this.pixelData.push(rgb.r,rgb.g,rgb.b,this.getAlphaValue(alpha)));}
+return _results;};PSDImage.prototype.combineLAB16Channel=function(){var a,alpha,b,i,l,rgb,_i,_ref,_results;_results=[];for(i=_i=0,_ref=this.numPixels;_i<_ref;i=_i+=2){if(this.getImageChannels()===4){alpha=this.channelData[i];l=this.channelData[i+this.channelLength];a=this.channelData[i+this.channelLength*2];b=this.channelData[i+this.channelLength*3];}else{alpha=255;l=this.channelData[i];a=this.channelData[i+this.channelLength];b=this.channelData[i+this.channelLength*2];}
+rgb=PSDColor.labToRGB(l*100>>8,a-128,b-128);_results.push(this.pixelData.push(rgb.r,rgb.g,rgb.b,this.getAlphaValue(alpha)));}
return _results;};PSDImage.prototype.combineMultiChannel8=function(){var c,i,k,m,rgb,y,_i,_ref,_results;_results=[];for(i=_i=0,_ref=this.numPixels;0<=_ref?_i<_ref:_i>_ref;i=0<=_ref?++_i:--_i){c=this.channelData[i];m=this.channelData[i+this.channelLength];y=this.channelData[i+this.channelLength*2];if(this.getImageChannels()===4){k=this.channelData[i+this.channelLength*3];}else{k=255;}
rgb=PSDColor.cmykToRGB(255-c,255-m,255-y,255-k);_results.push(this.pixelData.push(rgb.r,rgb.g,rgb.b,this.getAlphaValue(255)));}
return _results;};PSDImage.prototype.toCanvasPixels=function(){return this.pixelData;};PSDImage.prototype.toFile=function(filename,cb){var png;if(this.toCanvasPixels().length===0){return cb();}
diff --git a/src/psdimage.coffee b/src/psdimage.coffee
index 03c1f57..35f8bbd 100755
--- a/src/psdimage.coffee
+++ b/src/psdimage.coffee
@@ -301,6 +301,23 @@ class PSDImage
@pixelData.push rgb.r, rgb.g, rgb.b, @getAlphaValue(alpha)
+ combineLAB16Channel: ->
+ for i in [0...@numPixels] by 2
+ if @getImageChannels() is 4
+ alpha = @channelData[i]
+ l = @channelData[i + @channelLength]
+ a = @channelData[i + @channelLength * 2]
+ b = @channelData[i + @channelLength * 3]
+ else
+ alpha = 255
+ l = @channelData[i]
+ a = @channelData[i + @channelLength]
+ b = @channelData[i + @channelLength * 2]
+
+ rgb = PSDColor.labToRGB l * 100 >> 8, a - 128, b - 128
+
+ @pixelData.push rgb.r, rgb.g, rgb.b, @getAlphaValue(alpha)
+
combineMultiChannel8: ->
for i in [0...@numPixels]
c = @channelData[i]