emf-converter 4.18.0 → 4.18.1

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
@@ -29639,6 +29639,12 @@ function gdiDevicePixelX(r) {
29639
29639
  function gdiDevicePixelY(r) {
29640
29640
  return !r.useMappingMode || r.deviceToCanvas ? r.sy : 1;
29641
29641
  }
29642
+ function gdiDeviceToCanvasX(r, x) {
29643
+ return !r.useMappingMode || r.deviceToCanvas ? (x - r.bounds.left) * r.sx : x;
29644
+ }
29645
+ function gdiDeviceToCanvasY(r, y) {
29646
+ return !r.useMappingMode || r.deviceToCanvas ? (y - r.bounds.top) * r.sy : y;
29647
+ }
29642
29648
  function activateGdiMappingMode(r) {
29643
29649
  r.useMappingMode = true;
29644
29650
  }
@@ -37234,11 +37240,13 @@ function handleExtSelectClipRgn(rCtx, dataOff, recSize) {
37234
37240
  const top = view.getInt32(rOff + 4, true);
37235
37241
  const right = view.getInt32(rOff + 8, true);
37236
37242
  const bottom = view.getInt32(rOff + 12, true);
37243
+ const x = gdiDeviceToCanvasX(rCtx, left);
37244
+ const y = gdiDeviceToCanvasY(rCtx, top);
37237
37245
  rects.push({
37238
- x: gmx(rCtx, left),
37239
- y: gmy(rCtx, top),
37240
- w: gmw(rCtx, right - left),
37241
- h: gmh(rCtx, bottom - top)
37246
+ x,
37247
+ y,
37248
+ w: gdiDeviceToCanvasX(rCtx, right) - x,
37249
+ h: gdiDeviceToCanvasY(rCtx, bottom) - y
37242
37250
  });
37243
37251
  }
37244
37252
  if (rects.length === 0) {
@@ -37253,7 +37261,11 @@ function handleOffsetClipRgn(rCtx, dataOff, recSize) {
37253
37261
  const dx = rCtx.view.getInt32(dataOff, true);
37254
37262
  const dy = rCtx.view.getInt32(dataOff + 4, true);
37255
37263
  if (rCtx.clipRegion) {
37256
- rCtx.clipRegion = translateClipRegion(rCtx.clipRegion, gmw(rCtx, dx), gmh(rCtx, dy));
37264
+ const px = gdiDevicePixelX(rCtx);
37265
+ const py = gdiDevicePixelY(rCtx);
37266
+ const ox = Math.round(gmw(rCtx, dx) / px) * px;
37267
+ const oy = Math.round(gmh(rCtx, dy) / py) * py;
37268
+ rCtx.clipRegion = translateClipRegion(rCtx.clipRegion, ox, oy);
37257
37269
  reapplyClipRegion(rCtx, rCtx.clipRegion);
37258
37270
  }
37259
37271
  }
package/dist/browser.mjs CHANGED
@@ -29637,6 +29637,12 @@ function gdiDevicePixelX(r) {
29637
29637
  function gdiDevicePixelY(r) {
29638
29638
  return !r.useMappingMode || r.deviceToCanvas ? r.sy : 1;
29639
29639
  }
29640
+ function gdiDeviceToCanvasX(r, x) {
29641
+ return !r.useMappingMode || r.deviceToCanvas ? (x - r.bounds.left) * r.sx : x;
29642
+ }
29643
+ function gdiDeviceToCanvasY(r, y) {
29644
+ return !r.useMappingMode || r.deviceToCanvas ? (y - r.bounds.top) * r.sy : y;
29645
+ }
29640
29646
  function activateGdiMappingMode(r) {
29641
29647
  r.useMappingMode = true;
29642
29648
  }
@@ -37232,11 +37238,13 @@ function handleExtSelectClipRgn(rCtx, dataOff, recSize) {
37232
37238
  const top = view.getInt32(rOff + 4, true);
37233
37239
  const right = view.getInt32(rOff + 8, true);
37234
37240
  const bottom = view.getInt32(rOff + 12, true);
37241
+ const x = gdiDeviceToCanvasX(rCtx, left);
37242
+ const y = gdiDeviceToCanvasY(rCtx, top);
37235
37243
  rects.push({
37236
- x: gmx(rCtx, left),
37237
- y: gmy(rCtx, top),
37238
- w: gmw(rCtx, right - left),
37239
- h: gmh(rCtx, bottom - top)
37244
+ x,
37245
+ y,
37246
+ w: gdiDeviceToCanvasX(rCtx, right) - x,
37247
+ h: gdiDeviceToCanvasY(rCtx, bottom) - y
37240
37248
  });
37241
37249
  }
37242
37250
  if (rects.length === 0) {
@@ -37251,7 +37259,11 @@ function handleOffsetClipRgn(rCtx, dataOff, recSize) {
37251
37259
  const dx = rCtx.view.getInt32(dataOff, true);
37252
37260
  const dy = rCtx.view.getInt32(dataOff + 4, true);
37253
37261
  if (rCtx.clipRegion) {
37254
- rCtx.clipRegion = translateClipRegion(rCtx.clipRegion, gmw(rCtx, dx), gmh(rCtx, dy));
37262
+ const px = gdiDevicePixelX(rCtx);
37263
+ const py = gdiDevicePixelY(rCtx);
37264
+ const ox = Math.round(gmw(rCtx, dx) / px) * px;
37265
+ const oy = Math.round(gmh(rCtx, dy) / py) * py;
37266
+ rCtx.clipRegion = translateClipRegion(rCtx.clipRegion, ox, oy);
37255
37267
  reapplyClipRegion(rCtx, rCtx.clipRegion);
37256
37268
  }
37257
37269
  }
package/dist/index.js CHANGED
@@ -29640,6 +29640,12 @@ function gdiDevicePixelX(r) {
29640
29640
  function gdiDevicePixelY(r) {
29641
29641
  return !r.useMappingMode || r.deviceToCanvas ? r.sy : 1;
29642
29642
  }
29643
+ function gdiDeviceToCanvasX(r, x) {
29644
+ return !r.useMappingMode || r.deviceToCanvas ? (x - r.bounds.left) * r.sx : x;
29645
+ }
29646
+ function gdiDeviceToCanvasY(r, y) {
29647
+ return !r.useMappingMode || r.deviceToCanvas ? (y - r.bounds.top) * r.sy : y;
29648
+ }
29643
29649
  function activateGdiMappingMode(r) {
29644
29650
  r.useMappingMode = true;
29645
29651
  }
@@ -37235,11 +37241,13 @@ function handleExtSelectClipRgn(rCtx, dataOff, recSize) {
37235
37241
  const top = view.getInt32(rOff + 4, true);
37236
37242
  const right = view.getInt32(rOff + 8, true);
37237
37243
  const bottom = view.getInt32(rOff + 12, true);
37244
+ const x = gdiDeviceToCanvasX(rCtx, left);
37245
+ const y = gdiDeviceToCanvasY(rCtx, top);
37238
37246
  rects.push({
37239
- x: gmx(rCtx, left),
37240
- y: gmy(rCtx, top),
37241
- w: gmw(rCtx, right - left),
37242
- h: gmh(rCtx, bottom - top)
37247
+ x,
37248
+ y,
37249
+ w: gdiDeviceToCanvasX(rCtx, right) - x,
37250
+ h: gdiDeviceToCanvasY(rCtx, bottom) - y
37243
37251
  });
37244
37252
  }
37245
37253
  if (rects.length === 0) {
@@ -37254,7 +37262,11 @@ function handleOffsetClipRgn(rCtx, dataOff, recSize) {
37254
37262
  const dx = rCtx.view.getInt32(dataOff, true);
37255
37263
  const dy = rCtx.view.getInt32(dataOff + 4, true);
37256
37264
  if (rCtx.clipRegion) {
37257
- rCtx.clipRegion = translateClipRegion(rCtx.clipRegion, gmw(rCtx, dx), gmh(rCtx, dy));
37265
+ const px = gdiDevicePixelX(rCtx);
37266
+ const py = gdiDevicePixelY(rCtx);
37267
+ const ox = Math.round(gmw(rCtx, dx) / px) * px;
37268
+ const oy = Math.round(gmh(rCtx, dy) / py) * py;
37269
+ rCtx.clipRegion = translateClipRegion(rCtx.clipRegion, ox, oy);
37258
37270
  reapplyClipRegion(rCtx, rCtx.clipRegion);
37259
37271
  }
37260
37272
  }
package/dist/index.mjs CHANGED
@@ -29638,6 +29638,12 @@ function gdiDevicePixelX(r) {
29638
29638
  function gdiDevicePixelY(r) {
29639
29639
  return !r.useMappingMode || r.deviceToCanvas ? r.sy : 1;
29640
29640
  }
29641
+ function gdiDeviceToCanvasX(r, x) {
29642
+ return !r.useMappingMode || r.deviceToCanvas ? (x - r.bounds.left) * r.sx : x;
29643
+ }
29644
+ function gdiDeviceToCanvasY(r, y) {
29645
+ return !r.useMappingMode || r.deviceToCanvas ? (y - r.bounds.top) * r.sy : y;
29646
+ }
29641
29647
  function activateGdiMappingMode(r) {
29642
29648
  r.useMappingMode = true;
29643
29649
  }
@@ -37233,11 +37239,13 @@ function handleExtSelectClipRgn(rCtx, dataOff, recSize) {
37233
37239
  const top = view.getInt32(rOff + 4, true);
37234
37240
  const right = view.getInt32(rOff + 8, true);
37235
37241
  const bottom = view.getInt32(rOff + 12, true);
37242
+ const x = gdiDeviceToCanvasX(rCtx, left);
37243
+ const y = gdiDeviceToCanvasY(rCtx, top);
37236
37244
  rects.push({
37237
- x: gmx(rCtx, left),
37238
- y: gmy(rCtx, top),
37239
- w: gmw(rCtx, right - left),
37240
- h: gmh(rCtx, bottom - top)
37245
+ x,
37246
+ y,
37247
+ w: gdiDeviceToCanvasX(rCtx, right) - x,
37248
+ h: gdiDeviceToCanvasY(rCtx, bottom) - y
37241
37249
  });
37242
37250
  }
37243
37251
  if (rects.length === 0) {
@@ -37252,7 +37260,11 @@ function handleOffsetClipRgn(rCtx, dataOff, recSize) {
37252
37260
  const dx = rCtx.view.getInt32(dataOff, true);
37253
37261
  const dy = rCtx.view.getInt32(dataOff + 4, true);
37254
37262
  if (rCtx.clipRegion) {
37255
- rCtx.clipRegion = translateClipRegion(rCtx.clipRegion, gmw(rCtx, dx), gmh(rCtx, dy));
37263
+ const px = gdiDevicePixelX(rCtx);
37264
+ const py = gdiDevicePixelY(rCtx);
37265
+ const ox = Math.round(gmw(rCtx, dx) / px) * px;
37266
+ const oy = Math.round(gmh(rCtx, dy) / py) * py;
37267
+ rCtx.clipRegion = translateClipRegion(rCtx.clipRegion, ox, oy);
37256
37268
  reapplyClipRegion(rCtx, rCtx.clipRegion);
37257
37269
  }
37258
37270
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emf-converter",
3
- "version": "4.18.0",
3
+ "version": "4.18.1",
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",