]> git.parisson.com Git - pdf.js.git/commitdiff
Merge branch 'master' into colorspace
authorsbarman <sbarman@L3CWZ5T.(none)>
Tue, 28 Jun 2011 21:23:56 +0000 (14:23 -0700)
committersbarman <sbarman@L3CWZ5T.(none)>
Tue, 28 Jun 2011 21:23:56 +0000 (14:23 -0700)
Conflicts:
pdf.js

1  2 
pdf.js

diff --cc pdf.js
index 8b9fefb2c265e8dd1f7390eb85645aacf0bf9266,3179f42ecd4ac0aa64d0ebafba72da956ca626af..bdb88a4a414a0027e433822a50a64216e70a8e6c
--- 1/pdf.js
--- 2/pdf.js
+++ b/pdf.js
@@@ -2230,8 -3255,43 +3255,46 @@@ var Encodings = 
    }
  };
  
+ var IDENTITY_MATRIX = [ 1, 0, 0, 1, 0, 0 ];
+ // <canvas> contexts store most of the state we need natively.
+ // However, PDF needs a bit more state, which we store here.
+ var CanvasExtraState = (function() {
+     function constructor() {
+         // Are soft masks and alpha values shapes or opacities?
+         this.alphaIsShape = false;
+         this.fontSize = 0;
+         this.textMatrix = IDENTITY_MATRIX;
+         this.leading = 0;
+         this.colorSpace = null;
+         // Current point (in user coordinates)
+         this.x = 0;
+         this.y = 0;
+         // Start of text line (in text coordinates)
+         this.lineX = 0;
+         this.lineY = 0;
+         // Character and word spacing
+         this.charSpace = 0;
+         this.wordSpace = 0;
+         this.textHScale = 100;
++        // Color spaces
++        this.fillColorSpace = null;
++        this.strokeColorSpace = null;
+     }
+     constructor.prototype = {
+     };
+     return constructor;
+ })();
+ function ScratchCanvas(width, height) {
+     var canvas = document.createElement("canvas");
+     canvas.width = width;
+     canvas.height = height;
+     return canvas;
+ }
  var CanvasGraphics = (function() {
-     function constructor(canvasCtx) {
+     function constructor(canvasCtx, imageCanvas) {
          this.ctx = canvasCtx;
          this.current = new CanvasExtraState();
          this.stateStack = [ ];
              var ri = (255 * r) | 0, gi = (255 * g) | 0, bi = (255 * b) | 0;
              return "rgb("+ ri +","+ gi +","+ bi +")";
          },
-         }
+         makeCssCmyk: function(c, m, y, k) {
+             // while waiting on CSS's cmyk()... http://www.ilkeratalay.com/colorspacesfaq.php#rgb
+             var ri = (255 * (1 - Math.min(1, c * (1 - k) + k))) | 0;
+             var gi = (255 * (1 - Math.min(1, m * (1 - k) + k))) | 0;
+             var bi = (255 * (1 - Math.min(1, y * (1 - k) + k))) | 0;
+             return "rgb("+ ri +","+ gi +","+ bi +")";
+         },
 +        getColorSpaceObj(colorSpace) {
 +            if (IsName(colorSpace)) {
 +                var name = colorSpace.name;
 +            } else if (IsArray(colorSpace)) {
 +                var name = colorSpace[0];
 +            }
 +        },
          // We generally keep the canvas context set for
          // nonzero-winding, and just set evenodd for the operations
          // that need them.