@react-native-ohos/react-native-image-crop-picker 0.40.5-rc.8 → 0.40.5
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/CHANGELOG.md +14 -0
- package/harmony/image_crop_picker/oh-package.json5 +1 -1
- package/harmony/image_crop_picker/src/main/ets/ImageCropPickerTurboModule.ts +8 -31
- package/harmony/image_crop_picker/src/main/ets/pages/ImageEditInfo.ets +3 -1
- package/harmony/image_crop_picker/src/main/ets/utils/EncodeUtil.ets +10 -37
- package/harmony/image_crop_picker.har +0 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
### v0.40.5-rc.11
|
|
4
|
+
|
|
5
|
+
- pre-release: @react-native-ohos/react-native-image-crop-picker@0.40.5-rc.11
|
|
6
|
+
|
|
7
|
+
### v0.40.5-rc.10
|
|
8
|
+
|
|
9
|
+
- fix: Adjust the saved format after image cropping and compression
|
|
10
|
+
- pre-release: @react-native-ohos/react-native-image-crop-picker@0.40.5-rc.10
|
|
11
|
+
|
|
12
|
+
### v0.40.5-rc.9
|
|
13
|
+
|
|
14
|
+
- fix: Add the "freeStyleCropEnabled" attribute
|
|
15
|
+
- pre-release: @react-native-ohos/react-native-image-crop-picker@0.40.5-rc.9
|
|
16
|
+
|
|
3
17
|
## v0.40.5-rc.1
|
|
4
18
|
- Fix the issue where the file size after compression is larger than the original file.
|
|
5
19
|
|
|
@@ -675,40 +675,17 @@ export class ImageCropPickerTurboModule extends TurboModule implements ImageCrop
|
|
|
675
675
|
let imageISs = image.createImageSource(files.fd);
|
|
676
676
|
let imagePMs = await imageISs.createPixelMap();
|
|
677
677
|
let imagePackerApi = await image.createImagePacker();
|
|
678
|
-
let jpgToJpeg = (imageType == 'jpg' ? 'jpeg' : imageType);
|
|
679
|
-
if (imageType == 'bmp') {
|
|
680
|
-
jpgToJpeg = 'jpeg';
|
|
681
|
-
}
|
|
682
678
|
let dstPath =
|
|
683
679
|
this.ctx.uiAbilityContext.tempDir + '/rn_image_crop_picker_lib_temp_' + util.generateRandomUUID(true) +
|
|
684
680
|
'.' + imageType;
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
// 只取第一帧压缩(保持与IOS一致) 同时将图片转为jpeg来处理压缩
|
|
694
|
-
let packerData = await packer.packToData(pixelMapList[0], options);
|
|
695
|
-
const number = fs.writeSync(newFile.fd, packerData);
|
|
696
|
-
fs.closeSync(newFile);
|
|
697
|
-
} else {
|
|
698
|
-
if(imageType == 'sdr_astc_4x4' || imageType == 'sdr_sut_superfast_4x4'){
|
|
699
|
-
quality = 92;
|
|
700
|
-
} else if(imageType == 'hdr_astc_4x4'){
|
|
701
|
-
quality = 85;
|
|
702
|
-
}
|
|
703
|
-
let options: image.PackingOption = {
|
|
704
|
-
format: `image/${jpgToJpeg}`,
|
|
705
|
-
quality: quality,
|
|
706
|
-
};
|
|
707
|
-
let newFile = fs.openSync(dstPath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
|
|
708
|
-
let packerData = await imagePackerApi.packToData(imagePMs, options);
|
|
709
|
-
const number = fs.writeSync(newFile.fd, packerData);
|
|
710
|
-
fs.closeSync(newFile);
|
|
711
|
-
}
|
|
681
|
+
let options: image.PackingOption = {
|
|
682
|
+
format: `image/jpeg`,
|
|
683
|
+
quality: quality,
|
|
684
|
+
};
|
|
685
|
+
let newFile = fs.openSync(dstPath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
|
|
686
|
+
let packerData = await imagePackerApi.packToData(imagePMs, options);
|
|
687
|
+
const number = fs.writeSync(newFile.fd, packerData);
|
|
688
|
+
fs.closeSync(newFile);
|
|
712
689
|
resultImages.push(dstPath);
|
|
713
690
|
fs.closeSync(files);
|
|
714
691
|
} else {
|
|
@@ -1234,7 +1234,9 @@ export struct ImageEditInfo {
|
|
|
1234
1234
|
return;
|
|
1235
1235
|
}
|
|
1236
1236
|
this.imageFlag = false;
|
|
1237
|
-
|
|
1237
|
+
if (!this.freeStyleCropEnabled) {
|
|
1238
|
+
return;
|
|
1239
|
+
}
|
|
1238
1240
|
let touch = event.touches[0];
|
|
1239
1241
|
let delX: number = touch.screenX - this.dragObj.x;
|
|
1240
1242
|
let delY: number = touch.screenY - this.dragObj.y;
|
|
@@ -11,48 +11,21 @@ import util from '@ohos.util';
|
|
|
11
11
|
const TAG: string = 'imageEdit_Encode';
|
|
12
12
|
|
|
13
13
|
export async function encode(component: Object, pixelMap: ESObject) : Promise<string> {
|
|
14
|
+
let imgPath: string = '';
|
|
14
15
|
const newPixelMap: ESObject = pixelMap;
|
|
15
16
|
const imagePackerApi = image.createImagePacker();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
let imageType = 'jpg';
|
|
20
|
-
if (i != -1) {
|
|
21
|
-
imageType = imagePath.substring(i + 1);
|
|
22
|
-
}
|
|
23
|
-
let jpgToJpeg = (imageType == 'jpg' ? 'jpeg' : imageType);
|
|
24
|
-
if (imageType == 'bmp') {
|
|
25
|
-
jpgToJpeg = 'jpeg';
|
|
17
|
+
const packOptions: image.PackingOption = {
|
|
18
|
+
format: Constants.ENCODE_FORMAT,
|
|
19
|
+
quality: Constants.ENCODE_QUALITY
|
|
26
20
|
}
|
|
21
|
+
let packerData = await imagePackerApi.packing(newPixelMap, packOptions);
|
|
27
22
|
const context = getContext(component);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
quality: 100,
|
|
33
|
-
};
|
|
34
|
-
let newFile = fs.openSync(dstPath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
|
|
35
|
-
let packerData = await imagePackerApi.packToData(newPixelMap, options);
|
|
36
|
-
const number = fs.writeSync(newFile.fd, packerData);
|
|
37
|
-
fs.closeSync(newFile);
|
|
38
|
-
} else {
|
|
39
|
-
let quality = Constants.ENCODE_QUALITY;
|
|
40
|
-
if(imageType == 'sdr_astc_4x4' || imageType == 'sdr_sut_superfast_4x4'){
|
|
41
|
-
quality = 92;
|
|
42
|
-
} else if(imageType == 'hdr_astc_4x4'){
|
|
43
|
-
quality = 85;
|
|
44
|
-
}
|
|
45
|
-
let options: image.PackingOption = {
|
|
46
|
-
format: `image/${jpgToJpeg}`,
|
|
47
|
-
quality: quality,
|
|
48
|
-
};
|
|
49
|
-
let newFile = fs.openSync(dstPath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
|
|
50
|
-
let packerData = await imagePackerApi.packToData(newPixelMap, options);
|
|
51
|
-
const number = fs.writeSync(newFile.fd, packerData);
|
|
52
|
-
fs.closeSync(newFile);
|
|
53
|
-
}
|
|
23
|
+
imgPath = context.tempDir + '/rn_image_crop_picker_lib_temp_' + util.generateRandomUUID(true) + Constants.IMAGE_FORMAT;
|
|
24
|
+
let newFile = fs.openSync(imgPath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
|
|
25
|
+
const number = fs.writeSync(newFile.fd, packerData);
|
|
26
|
+
fs.closeSync(newFile.fd);
|
|
54
27
|
imagePackerApi.release();
|
|
55
|
-
return
|
|
28
|
+
return imgPath;
|
|
56
29
|
}
|
|
57
30
|
|
|
58
31
|
// PNG编码函数
|
|
Binary file
|