diff --git a/camera/src/main/ets/cameramanagers/PhotoManager.ets b/camera/src/main/ets/cameramanagers/PhotoManager.ets index 4b94383960f5c15880839d9be355e7c36e1f6149..01956edacd6497001cccbec8376cceed4a23ca5a 100644 --- a/camera/src/main/ets/cameramanagers/PhotoManager.ets +++ b/camera/src/main/ets/cameramanagers/PhotoManager.ets @@ -20,7 +20,6 @@ import { sensor } from '@kit.SensorServiceKit'; import { Decimal } from '@kit.ArkTS'; import { image } from '@kit.ImageKit'; import OutputManager, { CreateOutputConfig } from './OutputManager'; -import CameraConstant from '../constants/CameraConstants'; import { colorSpaceManager } from '@kit.ArkGraphics2D'; import { geoLocationManager } from '@kit.LocationKit'; import { Logger } from 'commons/src/main/ets/utils/Logger'; @@ -154,44 +153,9 @@ export class PhotoManager implements OutputManager { Logger.error(TAG_LOG, 'getPhoto failed'); return; } - this.mediaLibSavePhotoSingle(photo.main, context) + this.mediaLibSavePhotoSingle(context, photo.main) }); } - - mediaLibSavePhotoSingle(imageObj: image.Image, context: Context) { - imageObj.getComponent(image.ComponentType.JPEG, async (errCode: BusinessError, component: image.Component) => { - Logger.info(LOG_TAG, 'getComponent start'); - if (errCode || component === undefined) { - Logger.error(LOG_TAG, 'getComponent failed'); - return; - } - let buffer: ArrayBuffer; - if (component.byteBuffer) { - buffer = component.byteBuffer; - } else { - Logger.error(LOG_TAG, 'byteBuffer is null'); - return; - } - let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE; - let extension: string = 'jpg'; - let options: photoAccessHelper.CreateOptions = { - title: 'testPhoto' - } - let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = - photoAccessHelper.MediaAssetChangeRequest.createAssetRequest(context, photoType, extension, options); - assetChangeRequest.addResource(photoAccessHelper.ResourceType.IMAGE_RESOURCE, buffer) - assetChangeRequest.saveCameraPhoto(); - let accessHelper: photoAccessHelper.PhotoAccessHelper = - photoAccessHelper.getPhotoAccessHelper(context); - await accessHelper.applyChanges(assetChangeRequest); - let imageSource = image.createImageSource(buffer); - let pixelmap = imageSource.createPixelMapSync(); - this.callback(pixelmap, assetChangeRequest.getAsset().uri); - accessHelper.release(); - imageObj.release(); - }); - } - // [End set_photo_cb_single] // [Start save_photo_single] @@ -336,23 +300,11 @@ export class PhotoManager implements OutputManager { colorSpaces = session.getSupportedColorSpaces(); } catch (error) { let err = error as BusinessError; - Logger.error(LOG_TAG,`The getSupportedColorSpaces call failed. error code: ${err.code}`); + Logger.error(TAG_LOG,`The getSupportedColorSpaces call failed. error code: ${err.code}`); } return colorSpaces; } - setColorSpaceBeforeCommitConfig(session: camera.PhotoSession, isHdr: boolean): void { - let colorSpace: colorSpaceManager.ColorSpace = - isHdr ? colorSpaceManager.ColorSpace.DISPLAY_P3 : colorSpaceManager.ColorSpace.SRGB; - let colorSpaces: Array = this.getSupportedColorSpaces(session); - let isSupportedColorSpaces = colorSpaces.indexOf(colorSpace) >= 0; - if (isSupportedColorSpaces) { - session.setColorSpace(colorSpace); - } else { - Logger.info(LOG_TAG,`colorSpace: ${colorSpace} is not support`); - } - } - // [Start get_photo_rotation] getPhotoRotation(photoOutput: camera.PhotoOutput, deviceDegree: number): camera.ImageRotation { let photoRotation: camera.ImageRotation = camera.ImageRotation.ROTATION_0; diff --git a/entry/src/main/ets/constants/Constants.ets b/entry/src/main/ets/constants/Constants.ets index 5a54fe08914b3757eab25158e6c98fff13125f69..63a319b6d0c08a541568b7e723e8fd367785b0b7 100644 --- a/entry/src/main/ets/constants/Constants.ets +++ b/entry/src/main/ets/constants/Constants.ets @@ -26,7 +26,6 @@ class CameraConstant { 'ohos.permission.READ_IMAGEVIDEO', 'ohos.permission.APPROXIMATELY_LOCATION' ]; - static readonly PROFILE_DIFFERENCE = 1e-10; } export default CameraConstant; \ No newline at end of file diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index e4effd6419d8fb8089dae253c15fbd363c77ac21..32d0de3f681b25d4009cffd841f63483b0e3a0d8 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -134,7 +134,7 @@ }, { "name": "permission_LOCATION", - "value": "用于地理位置" + "value": "For location" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json index 06cf5aeb40bd35672cf10bd4c9c17d6f852b6744..84573dc11ed7df2080447c4a2dcd36c44ccccd45 100644 --- a/entry/src/main/resources/en_US/element/string.json +++ b/entry/src/main/resources/en_US/element/string.json @@ -131,6 +131,10 @@ { "name": "preview_image_close", "value": "Dual-channel preview has been disabled" + }, + { + "name": "permission_LOCATION", + "value": "For location" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json index bcf0e2cff2c605952f27c43b5f8a8e261c465edf..5ec0a505fa7c75944cef88292a370e07d50dab8c 100644 --- a/entry/src/main/resources/zh_CN/element/string.json +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -131,6 +131,10 @@ { "name": "preview_image_close", "value": "双路预览已关闭" + }, + { + "name": "permission_LOCATION", + "value": "用于地理位置" } ] } \ No newline at end of file