Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of getAll usage in colorspace.js #6975

Merged
merged 1 commit into from
Feb 11, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 28 additions & 18 deletions src/core/colorspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,15 @@ var ColorSpace = (function ColorSpaceClosure() {
case 'DeviceCmykCS':
return this.singletons.cmyk;
case 'CalGrayCS':
whitePoint = IR[1].WhitePoint;
blackPoint = IR[1].BlackPoint;
gamma = IR[1].Gamma;
whitePoint = IR[1];
blackPoint = IR[2];
gamma = IR[3];
return new CalGrayCS(whitePoint, blackPoint, gamma);
case 'CalRGBCS':
whitePoint = IR[1].WhitePoint;
blackPoint = IR[1].BlackPoint;
gamma = IR[1].Gamma;
var matrix = IR[1].Matrix;
whitePoint = IR[1];
blackPoint = IR[2];
gamma = IR[3];
var matrix = IR[4];
return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
case 'PatternCS':
var basePatternCS = IR[1];
Expand All @@ -239,11 +239,11 @@ var ColorSpace = (function ColorSpaceClosure() {
var tintFnIR = IR[3];

return new AlternateCS(numComps, ColorSpace.fromIR(alt),
PDFFunction.fromIR(tintFnIR));
PDFFunction.fromIR(tintFnIR));
case 'LabCS':
whitePoint = IR[1].WhitePoint;
blackPoint = IR[1].BlackPoint;
var range = IR[1].Range;
whitePoint = IR[1];
blackPoint = IR[2];
var range = IR[3];
return new LabCS(whitePoint, blackPoint, range);
default:
error('Unknown name ' + name);
Expand Down Expand Up @@ -287,7 +287,7 @@ var ColorSpace = (function ColorSpaceClosure() {
} else if (isArray(cs)) {
mode = xref.fetchIfRef(cs[0]).name;
this.mode = mode;
var numComps, params, alt;
var numComps, params, alt, whitePoint, blackPoint, gamma;

switch (mode) {
case 'DeviceGray':
Expand All @@ -300,11 +300,18 @@ var ColorSpace = (function ColorSpaceClosure() {
case 'CMYK':
return 'DeviceCmykCS';
case 'CalGray':
params = xref.fetchIfRef(cs[1]).getAll();
return ['CalGrayCS', params];
params = xref.fetchIfRef(cs[1]);
whitePoint = params.get('WhitePoint');
blackPoint = params.get('BlackPoint');
gamma = params.get('Gamma');
return ['CalGrayCS', whitePoint, blackPoint, gamma];
case 'CalRGB':
params = xref.fetchIfRef(cs[1]).getAll();
return ['CalRGBCS', params];
params = xref.fetchIfRef(cs[1]);
whitePoint = params.get('WhitePoint');
blackPoint = params.get('BlackPoint');
gamma = params.get('Gamma');
var matrix = params.get('Matrix');
return ['CalRGBCS', whitePoint, blackPoint, gamma, matrix];
case 'ICCBased':
var stream = xref.fetchIfRef(cs[1]);
var dict = stream.dict;
Expand Down Expand Up @@ -356,8 +363,11 @@ var ColorSpace = (function ColorSpaceClosure() {
var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
return ['AlternateCS', numComps, alt, tintFnIR];
case 'Lab':
params = xref.fetchIfRef(cs[1]).getAll();
return ['LabCS', params];
params = xref.fetchIfRef(cs[1]);
whitePoint = params.get('WhitePoint');
blackPoint = params.get('BlackPoint');
var range = params.get('Range');
return ['LabCS', whitePoint, blackPoint, range];
default:
error('unimplemented color space object "' + mode + '"');
}
Expand Down