Skip to content

fix: 解决maxSize属性设置与生成图片尺寸不符问题,计算错误。 #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions harmony/rnoh_signature_capture/src/main/ets/SignatureCaptureArk.ets
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,21 @@ export struct SignatureCaptureArkView {
private getReSizePm() {
const pm = this.getCanvasPixMap();
const maxSize = this.descriptorWrapper.props.maxSize;
let width = this.context2D.width;
let height = this.context2D.height;
const ratio = width / height;
if (ratio > 1) {
width = maxSize;
height = width / ratio;
} else {
height = maxSize;
width = height * ratio;
if (maxSize) {
let width = this.context2D.width;
let height = this.context2D.height;
const ratio = width / height;
if (ratio > 1) {
width = maxSize;
height = width / ratio;
} else {
height = maxSize;
width = height * ratio;
}
let xScale = width / this.context2D.width / 3.25;
let yScale = height / this.context2D.height / 3.25;
pm.scaleSync(xScale, yScale);
}
let xScale = width / this.context2D.width;
let yScale = height / this.context2D.height;
pm.scaleSync(xScale, yScale);
return pm;
}

Expand Down
2 changes: 1 addition & 1 deletion src/SignatureCaptureNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface OutgoingAndIncomingData {
showBorder?: WithDefault<boolean, true>,
showNativeButtons?: WithDefault<boolean, true>,
showTitleLabel?: WithDefault<boolean, true>,
maxSize?: WithDefault<Int32, 500>,
maxSize?: Int32,
minStrokeWidth?: WithDefault<Float, 3>,
maxStrokeWidth?: WithDefault<Float, 6>,
strokeColor?: ProcessedColorValue | null,
Expand Down