Skip to content

Commit 34b2a54

Browse files
authored
fix(maxSize): 解决maxSize属性设置与生成图片尺寸不符问题,计算错误。 (#11)
1 parent 774023c commit 34b2a54

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

harmony/rnoh_signature_capture/src/main/ets/SignatureCaptureArk.ets

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,21 @@ export struct SignatureCaptureArkView {
177177
private getReSizePm() {
178178
const pm = this.getCanvasPixMap();
179179
const maxSize = this.descriptorWrapper.props.maxSize;
180-
let width = this.context2D.width;
181-
let height = this.context2D.height;
182-
const ratio = width / height;
183-
if (ratio > 1) {
184-
width = maxSize;
185-
height = width / ratio;
186-
} else {
187-
height = maxSize;
188-
width = height * ratio;
180+
if (maxSize) {
181+
let width = this.context2D.width;
182+
let height = this.context2D.height;
183+
const ratio = width / height;
184+
if (ratio > 1) {
185+
width = maxSize;
186+
height = width / ratio;
187+
} else {
188+
height = maxSize;
189+
width = height * ratio;
190+
}
191+
let xScale = width / this.context2D.width / 3.25;
192+
let yScale = height / this.context2D.height / 3.25;
193+
pm.scaleSync(xScale, yScale);
189194
}
190-
let xScale = width / this.context2D.width;
191-
let yScale = height / this.context2D.height;
192-
pm.scaleSync(xScale, yScale);
193195
return pm;
194196
}
195197

src/SignatureCaptureNativeComponent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface OutgoingAndIncomingData {
1818
showBorder?: WithDefault<boolean, true>,
1919
showNativeButtons?: WithDefault<boolean, true>,
2020
showTitleLabel?: WithDefault<boolean, true>,
21-
maxSize?: WithDefault<Int32, 500>,
21+
maxSize?: Int32,
2222
minStrokeWidth?: WithDefault<Float, 3>,
2323
maxStrokeWidth?: WithDefault<Float, 6>,
2424
strokeColor?: ProcessedColorValue | null,

0 commit comments

Comments
 (0)