modules/bmp_support.js

  1. import { JPEGEncoder } from "../libs/JPEGEncoder.js";
  2. import { BmpDecoder } from "../libs/BMPDecoder.js";
  3. import { jsPDF } from "../jspdf.js";
  4. /**
  5. * @license
  6. * Copyright (c) 2018 Aras Abbasi
  7. *
  8. * Licensed under the MIT License.
  9. * http://opensource.org/licenses/mit-license
  10. */
  11. /**
  12. * jsPDF bmp Support PlugIn
  13. * @name bmp_support
  14. * @module
  15. */
  16. (function(jsPDFAPI) {
  17. "use strict";
  18. jsPDFAPI.processBMP = function(imageData, index, alias, compression) {
  19. var reader = new BmpDecoder(imageData, false);
  20. var width = reader.width,
  21. height = reader.height;
  22. var qu = 100;
  23. var pixels = reader.getData();
  24. var rawImageData = {
  25. data: pixels,
  26. width: width,
  27. height: height
  28. };
  29. var encoder = new JPEGEncoder(qu);
  30. var data = encoder.encode(rawImageData, qu);
  31. return jsPDFAPI.processJPEG.call(this, data, index, alias, compression);
  32. };
  33. })(jsPDF.API);