emf-converter 4.8.14 → 4.8.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.js CHANGED
@@ -20434,7 +20434,7 @@ function axisFilter(kernel, scale, copy) {
20434
20434
  return { radius: 0.5, weight: (i, c) => Math.floor(c + 0.5) === i ? 1 : 0 };
20435
20435
  }
20436
20436
  }
20437
- function blendSeparable(rgba, width, box, iu0, wu, iv0, wv, verticalFirst, edge = { wrap: void 0, clamp: null }) {
20437
+ function blendSeparable(rgba, width, box, iu0, wu, iv0, wv, verticalFirst, edge = { wrap: void 0, clamp: null }, integerBicubic = false) {
20438
20438
  const [outer0, outerW, inner0, innerW] = verticalFirst ? [iu0, wu, iv0, wv] : [iv0, wv, iu0, wu];
20439
20439
  const [oMin, oMax, iMin, iMax] = verticalFirst ? [box.x0, box.x1, box.y0, box.y1] : [box.y0, box.y1, box.x0, box.x1];
20440
20440
  let r = 0;
@@ -20475,11 +20475,17 @@ function blendSeparable(rgba, width, box, iu0, wu, iv0, wv, verticalFirst, edge
20475
20475
  }
20476
20476
  const alpha = px[s + 3];
20477
20477
  const wa = wi * alpha / 255;
20478
- lr += wa * px[s];
20479
- lg += wa * px[s + 1];
20480
- lb += wa * px[s + 2];
20478
+ lr += integerBicubic ? wi * Math.round(alpha * px[s] / 255) : wa * px[s];
20479
+ lg += integerBicubic ? wi * Math.round(alpha * px[s + 1] / 255) : wa * px[s + 1];
20480
+ lb += integerBicubic ? wi * Math.round(alpha * px[s + 2] / 255) : wa * px[s + 2];
20481
20481
  la += wi * alpha;
20482
20482
  }
20483
+ if (integerBicubic) {
20484
+ lr = Math.trunc(lr);
20485
+ lg = Math.trunc(lg);
20486
+ lb = Math.trunc(lb);
20487
+ la = Math.trunc(la);
20488
+ }
20483
20489
  la = Math.min(255, Math.max(0, la));
20484
20490
  r += wo * Math.min(la, Math.max(0, lr));
20485
20491
  g += wo * Math.min(la, Math.max(0, lg));
@@ -20527,6 +20533,7 @@ function resampleImage(rgba, width, height, spec, surface) {
20527
20533
  let kernel = spec.kernel;
20528
20534
  const hq = kernel === "hq-bilinear" || kernel === "hq-bicubic";
20529
20535
  const axisAligned = m[1] === 0 && m[2] === 0;
20536
+ const integerBicubic = kernel === "bicubic" && axisAligned;
20530
20537
  let farFade = false;
20531
20538
  let shiftX = 0;
20532
20539
  let shiftY = 0;
@@ -20608,12 +20615,17 @@ function resampleImage(rgba, width, height, spec, surface) {
20608
20615
  mirrorX: spec.wrap === "tile-flip-x" || spec.wrap === "tile-flip-xy",
20609
20616
  mirrorY: spec.wrap === "tile-flip-y" || spec.wrap === "tile-flip-xy"
20610
20617
  };
20618
+ const bicubicDu = Math.round(inv2[0] * FIX16);
20619
+ const bicubicDv = Math.round(inv2[1] * FIX16);
20611
20620
  for (let j = 0; j < h; j++) {
20612
20621
  const py = by0 + j + o;
20622
+ let start = -1;
20623
+ let su = 0;
20624
+ let sv = 0;
20613
20625
  for (let i = 0; i < w; i++) {
20614
20626
  const px = bx0 + i + o;
20615
- const u = inv2[0] * (px - shiftX) + inv2[2] * (py - shiftY) + inv2[4];
20616
- const v = inv2[1] * (px - shiftX) + inv2[3] * (py - shiftY) + inv2[5];
20627
+ let u = inv2[0] * (px - shiftX) + inv2[2] * (py - shiftY) + inv2[4];
20628
+ let v = inv2[1] * (px - shiftX) + inv2[3] * (py - shiftY) + inv2[5];
20617
20629
  const cx = px + COVERAGE_NUDGE_X;
20618
20630
  const cy = py + COVERAGE_NUDGE_Y;
20619
20631
  const eu = inv2[0] * cx + inv2[2] * cy + inv2[4];
@@ -20621,6 +20633,15 @@ function resampleImage(rgba, width, height, spec, surface) {
20621
20633
  if (eu < spec.srcX || ev < spec.srcY || eu >= uMax || ev >= vMax) {
20622
20634
  continue;
20623
20635
  }
20636
+ if (integerBicubic) {
20637
+ if (start < 0) {
20638
+ start = i;
20639
+ su = Math.round(u * FIX16);
20640
+ sv = Math.round(v * FIX16);
20641
+ }
20642
+ u = Math.floor((su + (i - start) * bicubicDu) / (FIX16 / 64)) / 64;
20643
+ v = Math.floor((sv + (i - start) * bicubicDv) / (FIX16 / 64)) / 64;
20644
+ }
20624
20645
  const box = { x0: 0, y0: 0, x1: width, y1: height };
20625
20646
  const sampleAt = (cu, cv) => {
20626
20647
  const iu0 = Math.ceil(cu - fu.radius);
@@ -20635,7 +20656,7 @@ function resampleImage(rgba, width, height, spec, surface) {
20635
20656
  for (let t = iv0; t <= iv1; t++) {
20636
20657
  wv.push(fv.weight(t, cv));
20637
20658
  }
20638
- return blendSeparable(rgba, width, box, iu0, wu, iv0, wv, kernel === "bicubic", edge);
20659
+ return blendSeparable(rgba, width, box, iu0, wu, iv0, wv, kernel === "bicubic", edge, integerBicubic);
20639
20660
  };
20640
20661
  let [r, g, b, a] = sampleAt(u, v);
20641
20662
  if (farFade && !spec.wrap && a > 0) {
@@ -20653,6 +20674,13 @@ function resampleImage(rgba, width, height, spec, surface) {
20653
20674
  if (a <= 0) {
20654
20675
  continue;
20655
20676
  }
20677
+ if (integerBicubic) {
20678
+ r = Math.trunc(r);
20679
+ g = Math.trunc(g);
20680
+ b = Math.trunc(b);
20681
+ a = Math.trunc(a);
20682
+ if (a <= 0) continue;
20683
+ }
20656
20684
  const alpha = Math.min(255, a);
20657
20685
  const dst = (j * w + i) * 4;
20658
20686
  out[dst] = Math.min(Math.max(0, r), alpha) * 255 / alpha;
@@ -22154,10 +22182,10 @@ var SvgContext = class {
22154
22182
  const parent = this.state.clipId;
22155
22183
  const id = this.id("c");
22156
22184
  const attrs = { id };
22185
+ const pathAttrs = { d: pathData(this.path, null) || "M0 0" };
22157
22186
  if (parent) {
22158
- attrs["clip-path"] = `url(#${parent})`;
22187
+ pathAttrs["clip-path"] = `url(#${parent})`;
22159
22188
  }
22160
- const pathAttrs = { d: pathData(this.path, null) || "M0 0" };
22161
22189
  if (fillRule === "evenodd") {
22162
22190
  pathAttrs["clip-rule"] = "evenodd";
22163
22191
  }
package/dist/browser.mjs CHANGED
@@ -20432,7 +20432,7 @@ function axisFilter(kernel, scale, copy) {
20432
20432
  return { radius: 0.5, weight: (i, c) => Math.floor(c + 0.5) === i ? 1 : 0 };
20433
20433
  }
20434
20434
  }
20435
- function blendSeparable(rgba, width, box, iu0, wu, iv0, wv, verticalFirst, edge = { wrap: void 0, clamp: null }) {
20435
+ function blendSeparable(rgba, width, box, iu0, wu, iv0, wv, verticalFirst, edge = { wrap: void 0, clamp: null }, integerBicubic = false) {
20436
20436
  const [outer0, outerW, inner0, innerW] = verticalFirst ? [iu0, wu, iv0, wv] : [iv0, wv, iu0, wu];
20437
20437
  const [oMin, oMax, iMin, iMax] = verticalFirst ? [box.x0, box.x1, box.y0, box.y1] : [box.y0, box.y1, box.x0, box.x1];
20438
20438
  let r = 0;
@@ -20473,11 +20473,17 @@ function blendSeparable(rgba, width, box, iu0, wu, iv0, wv, verticalFirst, edge
20473
20473
  }
20474
20474
  const alpha = px[s + 3];
20475
20475
  const wa = wi * alpha / 255;
20476
- lr += wa * px[s];
20477
- lg += wa * px[s + 1];
20478
- lb += wa * px[s + 2];
20476
+ lr += integerBicubic ? wi * Math.round(alpha * px[s] / 255) : wa * px[s];
20477
+ lg += integerBicubic ? wi * Math.round(alpha * px[s + 1] / 255) : wa * px[s + 1];
20478
+ lb += integerBicubic ? wi * Math.round(alpha * px[s + 2] / 255) : wa * px[s + 2];
20479
20479
  la += wi * alpha;
20480
20480
  }
20481
+ if (integerBicubic) {
20482
+ lr = Math.trunc(lr);
20483
+ lg = Math.trunc(lg);
20484
+ lb = Math.trunc(lb);
20485
+ la = Math.trunc(la);
20486
+ }
20481
20487
  la = Math.min(255, Math.max(0, la));
20482
20488
  r += wo * Math.min(la, Math.max(0, lr));
20483
20489
  g += wo * Math.min(la, Math.max(0, lg));
@@ -20525,6 +20531,7 @@ function resampleImage(rgba, width, height, spec, surface) {
20525
20531
  let kernel = spec.kernel;
20526
20532
  const hq = kernel === "hq-bilinear" || kernel === "hq-bicubic";
20527
20533
  const axisAligned = m[1] === 0 && m[2] === 0;
20534
+ const integerBicubic = kernel === "bicubic" && axisAligned;
20528
20535
  let farFade = false;
20529
20536
  let shiftX = 0;
20530
20537
  let shiftY = 0;
@@ -20606,12 +20613,17 @@ function resampleImage(rgba, width, height, spec, surface) {
20606
20613
  mirrorX: spec.wrap === "tile-flip-x" || spec.wrap === "tile-flip-xy",
20607
20614
  mirrorY: spec.wrap === "tile-flip-y" || spec.wrap === "tile-flip-xy"
20608
20615
  };
20616
+ const bicubicDu = Math.round(inv2[0] * FIX16);
20617
+ const bicubicDv = Math.round(inv2[1] * FIX16);
20609
20618
  for (let j = 0; j < h; j++) {
20610
20619
  const py = by0 + j + o;
20620
+ let start = -1;
20621
+ let su = 0;
20622
+ let sv = 0;
20611
20623
  for (let i = 0; i < w; i++) {
20612
20624
  const px = bx0 + i + o;
20613
- const u = inv2[0] * (px - shiftX) + inv2[2] * (py - shiftY) + inv2[4];
20614
- const v = inv2[1] * (px - shiftX) + inv2[3] * (py - shiftY) + inv2[5];
20625
+ let u = inv2[0] * (px - shiftX) + inv2[2] * (py - shiftY) + inv2[4];
20626
+ let v = inv2[1] * (px - shiftX) + inv2[3] * (py - shiftY) + inv2[5];
20615
20627
  const cx = px + COVERAGE_NUDGE_X;
20616
20628
  const cy = py + COVERAGE_NUDGE_Y;
20617
20629
  const eu = inv2[0] * cx + inv2[2] * cy + inv2[4];
@@ -20619,6 +20631,15 @@ function resampleImage(rgba, width, height, spec, surface) {
20619
20631
  if (eu < spec.srcX || ev < spec.srcY || eu >= uMax || ev >= vMax) {
20620
20632
  continue;
20621
20633
  }
20634
+ if (integerBicubic) {
20635
+ if (start < 0) {
20636
+ start = i;
20637
+ su = Math.round(u * FIX16);
20638
+ sv = Math.round(v * FIX16);
20639
+ }
20640
+ u = Math.floor((su + (i - start) * bicubicDu) / (FIX16 / 64)) / 64;
20641
+ v = Math.floor((sv + (i - start) * bicubicDv) / (FIX16 / 64)) / 64;
20642
+ }
20622
20643
  const box = { x0: 0, y0: 0, x1: width, y1: height };
20623
20644
  const sampleAt = (cu, cv) => {
20624
20645
  const iu0 = Math.ceil(cu - fu.radius);
@@ -20633,7 +20654,7 @@ function resampleImage(rgba, width, height, spec, surface) {
20633
20654
  for (let t = iv0; t <= iv1; t++) {
20634
20655
  wv.push(fv.weight(t, cv));
20635
20656
  }
20636
- return blendSeparable(rgba, width, box, iu0, wu, iv0, wv, kernel === "bicubic", edge);
20657
+ return blendSeparable(rgba, width, box, iu0, wu, iv0, wv, kernel === "bicubic", edge, integerBicubic);
20637
20658
  };
20638
20659
  let [r, g, b, a] = sampleAt(u, v);
20639
20660
  if (farFade && !spec.wrap && a > 0) {
@@ -20651,6 +20672,13 @@ function resampleImage(rgba, width, height, spec, surface) {
20651
20672
  if (a <= 0) {
20652
20673
  continue;
20653
20674
  }
20675
+ if (integerBicubic) {
20676
+ r = Math.trunc(r);
20677
+ g = Math.trunc(g);
20678
+ b = Math.trunc(b);
20679
+ a = Math.trunc(a);
20680
+ if (a <= 0) continue;
20681
+ }
20654
20682
  const alpha = Math.min(255, a);
20655
20683
  const dst = (j * w + i) * 4;
20656
20684
  out[dst] = Math.min(Math.max(0, r), alpha) * 255 / alpha;
@@ -22152,10 +22180,10 @@ var SvgContext = class {
22152
22180
  const parent = this.state.clipId;
22153
22181
  const id = this.id("c");
22154
22182
  const attrs = { id };
22183
+ const pathAttrs = { d: pathData(this.path, null) || "M0 0" };
22155
22184
  if (parent) {
22156
- attrs["clip-path"] = `url(#${parent})`;
22185
+ pathAttrs["clip-path"] = `url(#${parent})`;
22157
22186
  }
22158
- const pathAttrs = { d: pathData(this.path, null) || "M0 0" };
22159
22187
  if (fillRule === "evenodd") {
22160
22188
  pathAttrs["clip-rule"] = "evenodd";
22161
22189
  }
package/dist/index.d.mts CHANGED
@@ -222,9 +222,10 @@ interface SvgConvertOptions extends EmfConvertOptions {
222
222
  * PNG output's `InterpolationMode`/`PixelOffsetMode` model), so the SVG
223
223
  * shows what GDI+ painted pixel for pixel at its nominal size. PNG and
224
224
  * BMP images are decoded in pure JavaScript; JPEG, GIF and other formats
225
- * need a canvas backend to decode and otherwise keep `'renderer'`
226
- * scaling, as do draws GDI+ scales with a filter the resampler does not
227
- * model (bicubic, high-quality).
225
+ * use the available image decoder and otherwise keep `'renderer'`
226
+ * scaling. The resampler covers nearest-neighbour, bilinear, bicubic
227
+ * and high-quality modes; its remaining native differences also apply
228
+ * to the baked SVG pixels.
228
229
  */
229
230
  imageResampling?: 'renderer' | 'exact';
230
231
  /**
package/dist/index.d.ts CHANGED
@@ -222,9 +222,10 @@ interface SvgConvertOptions extends EmfConvertOptions {
222
222
  * PNG output's `InterpolationMode`/`PixelOffsetMode` model), so the SVG
223
223
  * shows what GDI+ painted pixel for pixel at its nominal size. PNG and
224
224
  * BMP images are decoded in pure JavaScript; JPEG, GIF and other formats
225
- * need a canvas backend to decode and otherwise keep `'renderer'`
226
- * scaling, as do draws GDI+ scales with a filter the resampler does not
227
- * model (bicubic, high-quality).
225
+ * use the available image decoder and otherwise keep `'renderer'`
226
+ * scaling. The resampler covers nearest-neighbour, bilinear, bicubic
227
+ * and high-quality modes; its remaining native differences also apply
228
+ * to the baked SVG pixels.
228
229
  */
229
230
  imageResampling?: 'renderer' | 'exact';
230
231
  /**
package/dist/index.js CHANGED
@@ -20435,7 +20435,7 @@ function axisFilter(kernel, scale, copy) {
20435
20435
  return { radius: 0.5, weight: (i, c) => Math.floor(c + 0.5) === i ? 1 : 0 };
20436
20436
  }
20437
20437
  }
20438
- function blendSeparable(rgba, width, box, iu0, wu, iv0, wv, verticalFirst, edge = { wrap: void 0, clamp: null }) {
20438
+ function blendSeparable(rgba, width, box, iu0, wu, iv0, wv, verticalFirst, edge = { wrap: void 0, clamp: null }, integerBicubic = false) {
20439
20439
  const [outer0, outerW, inner0, innerW] = verticalFirst ? [iu0, wu, iv0, wv] : [iv0, wv, iu0, wu];
20440
20440
  const [oMin, oMax, iMin, iMax] = verticalFirst ? [box.x0, box.x1, box.y0, box.y1] : [box.y0, box.y1, box.x0, box.x1];
20441
20441
  let r = 0;
@@ -20476,11 +20476,17 @@ function blendSeparable(rgba, width, box, iu0, wu, iv0, wv, verticalFirst, edge
20476
20476
  }
20477
20477
  const alpha = px[s + 3];
20478
20478
  const wa = wi * alpha / 255;
20479
- lr += wa * px[s];
20480
- lg += wa * px[s + 1];
20481
- lb += wa * px[s + 2];
20479
+ lr += integerBicubic ? wi * Math.round(alpha * px[s] / 255) : wa * px[s];
20480
+ lg += integerBicubic ? wi * Math.round(alpha * px[s + 1] / 255) : wa * px[s + 1];
20481
+ lb += integerBicubic ? wi * Math.round(alpha * px[s + 2] / 255) : wa * px[s + 2];
20482
20482
  la += wi * alpha;
20483
20483
  }
20484
+ if (integerBicubic) {
20485
+ lr = Math.trunc(lr);
20486
+ lg = Math.trunc(lg);
20487
+ lb = Math.trunc(lb);
20488
+ la = Math.trunc(la);
20489
+ }
20484
20490
  la = Math.min(255, Math.max(0, la));
20485
20491
  r += wo * Math.min(la, Math.max(0, lr));
20486
20492
  g += wo * Math.min(la, Math.max(0, lg));
@@ -20528,6 +20534,7 @@ function resampleImage(rgba, width, height, spec, surface) {
20528
20534
  let kernel = spec.kernel;
20529
20535
  const hq = kernel === "hq-bilinear" || kernel === "hq-bicubic";
20530
20536
  const axisAligned = m[1] === 0 && m[2] === 0;
20537
+ const integerBicubic = kernel === "bicubic" && axisAligned;
20531
20538
  let farFade = false;
20532
20539
  let shiftX = 0;
20533
20540
  let shiftY = 0;
@@ -20609,12 +20616,17 @@ function resampleImage(rgba, width, height, spec, surface) {
20609
20616
  mirrorX: spec.wrap === "tile-flip-x" || spec.wrap === "tile-flip-xy",
20610
20617
  mirrorY: spec.wrap === "tile-flip-y" || spec.wrap === "tile-flip-xy"
20611
20618
  };
20619
+ const bicubicDu = Math.round(inv2[0] * FIX16);
20620
+ const bicubicDv = Math.round(inv2[1] * FIX16);
20612
20621
  for (let j = 0; j < h; j++) {
20613
20622
  const py = by0 + j + o;
20623
+ let start = -1;
20624
+ let su = 0;
20625
+ let sv = 0;
20614
20626
  for (let i = 0; i < w; i++) {
20615
20627
  const px = bx0 + i + o;
20616
- const u = inv2[0] * (px - shiftX) + inv2[2] * (py - shiftY) + inv2[4];
20617
- const v = inv2[1] * (px - shiftX) + inv2[3] * (py - shiftY) + inv2[5];
20628
+ let u = inv2[0] * (px - shiftX) + inv2[2] * (py - shiftY) + inv2[4];
20629
+ let v = inv2[1] * (px - shiftX) + inv2[3] * (py - shiftY) + inv2[5];
20618
20630
  const cx = px + COVERAGE_NUDGE_X;
20619
20631
  const cy = py + COVERAGE_NUDGE_Y;
20620
20632
  const eu = inv2[0] * cx + inv2[2] * cy + inv2[4];
@@ -20622,6 +20634,15 @@ function resampleImage(rgba, width, height, spec, surface) {
20622
20634
  if (eu < spec.srcX || ev < spec.srcY || eu >= uMax || ev >= vMax) {
20623
20635
  continue;
20624
20636
  }
20637
+ if (integerBicubic) {
20638
+ if (start < 0) {
20639
+ start = i;
20640
+ su = Math.round(u * FIX16);
20641
+ sv = Math.round(v * FIX16);
20642
+ }
20643
+ u = Math.floor((su + (i - start) * bicubicDu) / (FIX16 / 64)) / 64;
20644
+ v = Math.floor((sv + (i - start) * bicubicDv) / (FIX16 / 64)) / 64;
20645
+ }
20625
20646
  const box = { x0: 0, y0: 0, x1: width, y1: height };
20626
20647
  const sampleAt = (cu, cv) => {
20627
20648
  const iu0 = Math.ceil(cu - fu.radius);
@@ -20636,7 +20657,7 @@ function resampleImage(rgba, width, height, spec, surface) {
20636
20657
  for (let t = iv0; t <= iv1; t++) {
20637
20658
  wv.push(fv.weight(t, cv));
20638
20659
  }
20639
- return blendSeparable(rgba, width, box, iu0, wu, iv0, wv, kernel === "bicubic", edge);
20660
+ return blendSeparable(rgba, width, box, iu0, wu, iv0, wv, kernel === "bicubic", edge, integerBicubic);
20640
20661
  };
20641
20662
  let [r, g, b, a] = sampleAt(u, v);
20642
20663
  if (farFade && !spec.wrap && a > 0) {
@@ -20654,6 +20675,13 @@ function resampleImage(rgba, width, height, spec, surface) {
20654
20675
  if (a <= 0) {
20655
20676
  continue;
20656
20677
  }
20678
+ if (integerBicubic) {
20679
+ r = Math.trunc(r);
20680
+ g = Math.trunc(g);
20681
+ b = Math.trunc(b);
20682
+ a = Math.trunc(a);
20683
+ if (a <= 0) continue;
20684
+ }
20657
20685
  const alpha = Math.min(255, a);
20658
20686
  const dst = (j * w + i) * 4;
20659
20687
  out[dst] = Math.min(Math.max(0, r), alpha) * 255 / alpha;
@@ -22155,10 +22183,10 @@ var SvgContext = class {
22155
22183
  const parent = this.state.clipId;
22156
22184
  const id = this.id("c");
22157
22185
  const attrs = { id };
22186
+ const pathAttrs = { d: pathData(this.path, null) || "M0 0" };
22158
22187
  if (parent) {
22159
- attrs["clip-path"] = `url(#${parent})`;
22188
+ pathAttrs["clip-path"] = `url(#${parent})`;
22160
22189
  }
22161
- const pathAttrs = { d: pathData(this.path, null) || "M0 0" };
22162
22190
  if (fillRule === "evenodd") {
22163
22191
  pathAttrs["clip-rule"] = "evenodd";
22164
22192
  }
package/dist/index.mjs CHANGED
@@ -20433,7 +20433,7 @@ function axisFilter(kernel, scale, copy) {
20433
20433
  return { radius: 0.5, weight: (i, c) => Math.floor(c + 0.5) === i ? 1 : 0 };
20434
20434
  }
20435
20435
  }
20436
- function blendSeparable(rgba, width, box, iu0, wu, iv0, wv, verticalFirst, edge = { wrap: void 0, clamp: null }) {
20436
+ function blendSeparable(rgba, width, box, iu0, wu, iv0, wv, verticalFirst, edge = { wrap: void 0, clamp: null }, integerBicubic = false) {
20437
20437
  const [outer0, outerW, inner0, innerW] = verticalFirst ? [iu0, wu, iv0, wv] : [iv0, wv, iu0, wu];
20438
20438
  const [oMin, oMax, iMin, iMax] = verticalFirst ? [box.x0, box.x1, box.y0, box.y1] : [box.y0, box.y1, box.x0, box.x1];
20439
20439
  let r = 0;
@@ -20474,11 +20474,17 @@ function blendSeparable(rgba, width, box, iu0, wu, iv0, wv, verticalFirst, edge
20474
20474
  }
20475
20475
  const alpha = px[s + 3];
20476
20476
  const wa = wi * alpha / 255;
20477
- lr += wa * px[s];
20478
- lg += wa * px[s + 1];
20479
- lb += wa * px[s + 2];
20477
+ lr += integerBicubic ? wi * Math.round(alpha * px[s] / 255) : wa * px[s];
20478
+ lg += integerBicubic ? wi * Math.round(alpha * px[s + 1] / 255) : wa * px[s + 1];
20479
+ lb += integerBicubic ? wi * Math.round(alpha * px[s + 2] / 255) : wa * px[s + 2];
20480
20480
  la += wi * alpha;
20481
20481
  }
20482
+ if (integerBicubic) {
20483
+ lr = Math.trunc(lr);
20484
+ lg = Math.trunc(lg);
20485
+ lb = Math.trunc(lb);
20486
+ la = Math.trunc(la);
20487
+ }
20482
20488
  la = Math.min(255, Math.max(0, la));
20483
20489
  r += wo * Math.min(la, Math.max(0, lr));
20484
20490
  g += wo * Math.min(la, Math.max(0, lg));
@@ -20526,6 +20532,7 @@ function resampleImage(rgba, width, height, spec, surface) {
20526
20532
  let kernel = spec.kernel;
20527
20533
  const hq = kernel === "hq-bilinear" || kernel === "hq-bicubic";
20528
20534
  const axisAligned = m[1] === 0 && m[2] === 0;
20535
+ const integerBicubic = kernel === "bicubic" && axisAligned;
20529
20536
  let farFade = false;
20530
20537
  let shiftX = 0;
20531
20538
  let shiftY = 0;
@@ -20607,12 +20614,17 @@ function resampleImage(rgba, width, height, spec, surface) {
20607
20614
  mirrorX: spec.wrap === "tile-flip-x" || spec.wrap === "tile-flip-xy",
20608
20615
  mirrorY: spec.wrap === "tile-flip-y" || spec.wrap === "tile-flip-xy"
20609
20616
  };
20617
+ const bicubicDu = Math.round(inv2[0] * FIX16);
20618
+ const bicubicDv = Math.round(inv2[1] * FIX16);
20610
20619
  for (let j = 0; j < h; j++) {
20611
20620
  const py = by0 + j + o;
20621
+ let start = -1;
20622
+ let su = 0;
20623
+ let sv = 0;
20612
20624
  for (let i = 0; i < w; i++) {
20613
20625
  const px = bx0 + i + o;
20614
- const u = inv2[0] * (px - shiftX) + inv2[2] * (py - shiftY) + inv2[4];
20615
- const v = inv2[1] * (px - shiftX) + inv2[3] * (py - shiftY) + inv2[5];
20626
+ let u = inv2[0] * (px - shiftX) + inv2[2] * (py - shiftY) + inv2[4];
20627
+ let v = inv2[1] * (px - shiftX) + inv2[3] * (py - shiftY) + inv2[5];
20616
20628
  const cx = px + COVERAGE_NUDGE_X;
20617
20629
  const cy = py + COVERAGE_NUDGE_Y;
20618
20630
  const eu = inv2[0] * cx + inv2[2] * cy + inv2[4];
@@ -20620,6 +20632,15 @@ function resampleImage(rgba, width, height, spec, surface) {
20620
20632
  if (eu < spec.srcX || ev < spec.srcY || eu >= uMax || ev >= vMax) {
20621
20633
  continue;
20622
20634
  }
20635
+ if (integerBicubic) {
20636
+ if (start < 0) {
20637
+ start = i;
20638
+ su = Math.round(u * FIX16);
20639
+ sv = Math.round(v * FIX16);
20640
+ }
20641
+ u = Math.floor((su + (i - start) * bicubicDu) / (FIX16 / 64)) / 64;
20642
+ v = Math.floor((sv + (i - start) * bicubicDv) / (FIX16 / 64)) / 64;
20643
+ }
20623
20644
  const box = { x0: 0, y0: 0, x1: width, y1: height };
20624
20645
  const sampleAt = (cu, cv) => {
20625
20646
  const iu0 = Math.ceil(cu - fu.radius);
@@ -20634,7 +20655,7 @@ function resampleImage(rgba, width, height, spec, surface) {
20634
20655
  for (let t = iv0; t <= iv1; t++) {
20635
20656
  wv.push(fv.weight(t, cv));
20636
20657
  }
20637
- return blendSeparable(rgba, width, box, iu0, wu, iv0, wv, kernel === "bicubic", edge);
20658
+ return blendSeparable(rgba, width, box, iu0, wu, iv0, wv, kernel === "bicubic", edge, integerBicubic);
20638
20659
  };
20639
20660
  let [r, g, b, a] = sampleAt(u, v);
20640
20661
  if (farFade && !spec.wrap && a > 0) {
@@ -20652,6 +20673,13 @@ function resampleImage(rgba, width, height, spec, surface) {
20652
20673
  if (a <= 0) {
20653
20674
  continue;
20654
20675
  }
20676
+ if (integerBicubic) {
20677
+ r = Math.trunc(r);
20678
+ g = Math.trunc(g);
20679
+ b = Math.trunc(b);
20680
+ a = Math.trunc(a);
20681
+ if (a <= 0) continue;
20682
+ }
20655
20683
  const alpha = Math.min(255, a);
20656
20684
  const dst = (j * w + i) * 4;
20657
20685
  out[dst] = Math.min(Math.max(0, r), alpha) * 255 / alpha;
@@ -22153,10 +22181,10 @@ var SvgContext = class {
22153
22181
  const parent = this.state.clipId;
22154
22182
  const id = this.id("c");
22155
22183
  const attrs = { id };
22184
+ const pathAttrs = { d: pathData(this.path, null) || "M0 0" };
22156
22185
  if (parent) {
22157
- attrs["clip-path"] = `url(#${parent})`;
22186
+ pathAttrs["clip-path"] = `url(#${parent})`;
22158
22187
  }
22159
- const pathAttrs = { d: pathData(this.path, null) || "M0 0" };
22160
22188
  if (fillRule === "evenodd") {
22161
22189
  pathAttrs["clip-rule"] = "evenodd";
22162
22190
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emf-converter",
3
- "version": "4.8.14",
3
+ "version": "4.8.16",
4
4
  "description": "Convert EMF/WMF metafile binaries to PNG data URLs or SVG (markup, data URL, React/JSX)",
5
5
  "keywords": [
6
6
  "canvas",