summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormeltingice <meltingice8917@gmail.com>2012-07-17 22:51:11 -0400
committermeltingice <meltingice8917@gmail.com>2012-07-17 22:51:11 -0400
commite2cd56940a2cd1b77f315b7200385af807011956 (patch)
treec9684246b33953f3bf420c95b08b63ec3f1b5ab1
parentUpdated documentation (diff)
downloadpsd.js-e2cd56940a2cd1b77f315b7200385af807011956.tar.xz
psd.js-e2cd56940a2cd1b77f315b7200385af807011956.zip
Simplify pad4 function
-rw-r--r--lib/psd.js2
-rw-r--r--lib/psd.min.js2
-rwxr-xr-xsrc/util.coffee2
3 files changed, 3 insertions, 3 deletions
diff --git a/lib/psd.js b/lib/psd.js
index 93ac499..24f1504 100644
--- a/lib/psd.js
+++ b/lib/psd.js
@@ -3714,7 +3714,7 @@ var jspack = new JSPack(); ;
};
Util.pad4 = function(i) {
- return (((i & 0xFF) + 1 + 3) & ~0x03) - 1;
+ return i - (i % 4) + 3;
};
Util.toUInt16 = function(b1, b2) {
diff --git a/lib/psd.min.js b/lib/psd.min.js
index b6d966b..1234357 100644
--- a/lib/psd.min.js
+++ b/lib/psd.min.js
@@ -282,7 +282,7 @@ _results.push(this.xpepBlocks.push(block));}
return _results;}},1053:{name:'Alpha Identifiers'},1054:{name:'URL List'},1057:{name:'Version Info'},1058:{name:'EXIF data 1'},1059:{name:'EXIF data 3'},1060:{name:'XMP metadata'},1061:{name:'Caption digest'},1062:{name:'Print scale'},1064:{name:'Pixel Aspect Ratio'},1065:{name:'Layer Comps'},1066:{name:'Alternate Duotone Colors'},1067:{name:'Alternate Spot Colors'},1069:{name:'Layer Selection ID(s)'},1070:{name:'HDR Toning information'},1071:{name:"Print info"},1072:{name:"Layer Groups Enabled"},1073:{name:"Color samplers resource"},1074:{name:"Measurement Scale"},1075:{name:"Timeline Information"},1076:{name:"Sheet Disclosure"},1077:{name:"DisplayInfo"},1078:{name:"Onion Skins"},1080:{name:"Count Information"},1082:{name:"Print Information"},1083:{name:"Print Style"},1084:{name:"Macintosh NSPrintInfo"},1085:{name:"Windows DEVMODE"},2999:{name:'Name of clipping path'},7000:{name:"Image Ready variables"},7001:{name:"Image Ready data sets"},8000:{name:"Lightroom workflow",parse:PSDResource.isLightroom=true},10000:{name:'Print flags info',parse:function(){var padding,_ref;return _ref=this.file.readf(">HBBLH"),this.version=_ref[0],this.centerCropMarks=_ref[1],padding=_ref[2],this.bleedWidth=_ref[3],this.bleedWidthScale=_ref[4],_ref;}}};function PSDResource(file){this.file=file;}
PSDResource.prototype.parse=function(){var n,resource,_ref,_ref1,_ref2;this.at=this.file.tell();_ref=this.file.readf(">4s H B"),this.type=_ref[0],this.id=_ref[1],this.namelen=_ref[2];Log.debug("Resource #"+this.id+": type="+this.type);n=Util.pad2(this.namelen+1)-1;this.name=this.file.readf(">"+n+"s")[0];this.name=this.name.substr(0,this.name.length-1);this.shortName=this.name.substr(0,20);this.size=this.file.readInt();this.size=Util.pad2(this.size);if((2000<=(_ref1=this.id)&&_ref1<=2998)){this.rdesc="[Path Information]";return this.file.seek(this.size);}else if(this.id===2999){return assert(0);}else if((4000<=(_ref2=this.id)&&_ref2<5000)){this.rdesc="[Plug-in Resource]";return this.file.seek(this.size);}else if(RESOURCE_DESCRIPTIONS[this.id]!=null){resource=RESOURCE_DESCRIPTIONS[this.id];this.rdesc="["+resource.name+"]";if(resource.parse!=null){return resource.parse.call(this);}else{return this.file.seek(this.size);}}else{return this.file.seek(this.size);}};PSDResource.prototype.toJSON=function(){var data,section,sections,_i,_len;sections=['type','id','name','rdesc'];data={};for(_i=0,_len=sections.length;_i<_len;_i++){section=sections[_i];data[section]=this[section];}
return data;};return PSDResource;})();Util=(function(){function Util(){}
-Util.pad2=function(i){return Math.floor((i+1)/2)*2;};Util.pad4=function(i){return(((i&0xFF)+1+3)&~0x03)-1;};Util.toUInt16=function(b1,b2){return(b1<<8)|b2;};Util.toInt16=function(b1,b2){var val;val=this.toUInt16(b1,b2);if(val>=0x8000){return val-0x10000;}else{return val;}};Util.round=function(num,sigFig){var mult;if(sigFig==null){sigFig=2;}
+Util.pad2=function(i){return Math.floor((i+1)/2)*2;};Util.pad4=function(i){return i-(i%4)+3;};Util.toUInt16=function(b1,b2){return(b1<<8)|b2;};Util.toInt16=function(b1,b2){var val;val=this.toUInt16(b1,b2);if(val>=0x8000){return val-0x10000;}else{return val;}};Util.round=function(num,sigFig){var mult;if(sigFig==null){sigFig=2;}
if(sigFig===0){return Math.round(num);}
mult=Math.pow(10,sigFig);return Math.round(num*mult)/mult;};Util.clamp=function(num,min,max){var i,val,_i,_len;if(min==null){min=Number.MIN_VALUE;}
if(max==null){max=Number.MAX_VALUE;}
diff --git a/src/util.coffee b/src/util.coffee
index 316b410..9ddff47 100755
--- a/src/util.coffee
+++ b/src/util.coffee
@@ -1,7 +1,7 @@
# "Static" utility functions
class Util
@pad2: (i) -> Math.floor((i + 1) / 2) * 2
- @pad4: (i) -> (((i & 0xFF) + 1 + 3) & ~0x03) - 1
+ @pad4: (i) -> i - (i % 4) + 3
@toUInt16: (b1, b2) -> (b1 << 8) | b2
@toInt16: (b1, b2) ->