fixed the display of images

This commit is contained in:
sbarman 2011-06-09 14:35:55 -07:00
parent cfff44f2b2
commit 496a6374c1

15
pdf.js
View File

@ -1897,6 +1897,17 @@ var CanvasGraphics = (function() {
return; return;
xobj = this.xref.fetchIfRef(xobj); xobj = this.xref.fetchIfRef(xobj);
assertWellFormed(IsStream(xobj), "XObject should be a stream"); assertWellFormed(IsStream(xobj), "XObject should be a stream");
var oc = xobj.dict.get("OC");
if (oc) {
TODO("oc for xobject");
}
var opi = xobj.dict.get("OPI");
if (opi) {
TODO("opi for xobject");
}
var type = xobj.dict.get("Subtype"); var type = xobj.dict.get("Subtype");
assertWellFormed(IsName(type), "XObject should have a Name subtype"); assertWellFormed(IsName(type), "XObject should have a Name subtype");
if ("Image" == type.name) { if ("Image" == type.name) {
@ -1932,7 +1943,6 @@ var CanvasGraphics = (function() {
paintImageXObject: function(image, inline) { paintImageXObject: function(image, inline) {
this.save(); this.save();
this.ctx.scale(.0066,.02);
if (image.getParams) { if (image.getParams) {
// JPX/JPEG2000 streams directly contain bits per component // JPX/JPEG2000 streams directly contain bits per component
// and color space mode information. // and color space mode information.
@ -1946,6 +1956,9 @@ var CanvasGraphics = (function() {
var w = dict.get("Width") || dict.get("W"); var w = dict.get("Width") || dict.get("W");
var h = dict.get("Height") || dict.get("H"); var h = dict.get("Height") || dict.get("H");
// scale the image to the unit square
this.ctx.scale(1/w, 1/h);
if (!IsNum(w) || !IsNum(h) || w < 1 || h < 1) if (!IsNum(w) || !IsNum(h) || w < 1 || h < 1)
error("Invalid image width or height"); error("Invalid image width or height");