define(["require", "exports", "./../../enumerator", "./../../graphics/pdf-graphics"], function (require, exports, enumerator_1, pdf_graphics_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var PdfImage = (function () {
function PdfImage() {
}
Object.defineProperty(PdfImage.prototype, "width", {
get: function () {
return this._imageWidth;
},
set: function (value) {
this._imageWidth = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(PdfImage.prototype, "height", {
get: function () {
return this._imageHeight;
},
set: function (value) {
this._imageHeight = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(PdfImage.prototype, "physicalDimension", {
get: function () {
this._imagePhysicalDimension = this._getPointSize(this.width, this.height, this._horizontalResolution);
return { width: this.width, height: this.height };
},
enumerable: true,
configurable: true
});
PdfImage.prototype.draw = function (graphics, location) {
if (location && (location.x === null || typeof location.x === 'undefined') && (location.y === null || typeof location.y === 'undefined')) {
location.x = 0;
location.y = 0;
}
var needSave;
if (location) {
needSave = (location.x !== 0 || location.y !== 0);
}
var state = null;
if (needSave) {
state = graphics.save();
graphics.translateTransform(location);
}
graphics.drawImage(this, { x: 0, y: 0 });
if (needSave) {
graphics.restore(state);
}
};
PdfImage.prototype._getPointSize = function (width, height, horizontalResolution) {
if ((horizontalResolution === null || typeof horizontalResolution === 'undefined')) {
var dpiX = 96;
var size = this._getPointSize(width, height, dpiX);
return size;
}
else {
var ucX = new pdf_graphics_1._PdfUnitConvertor();
var ucY = new pdf_graphics_1._PdfUnitConvertor();
var ptWidth = ucX._convertUnits(width, enumerator_1._PdfGraphicsUnit.pixel, enumerator_1._PdfGraphicsUnit.point);
var ptHeight = ucY._convertUnits(height, enumerator_1._PdfGraphicsUnit.pixel, enumerator_1._PdfGraphicsUnit.point);
var size = [ptWidth, ptHeight];
return size;
}
};
return PdfImage;
}());
exports.PdfImage = PdfImage;
});
|