| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| AppScope/ | 12-May-2024 | - | 37 | 34 | ||
| entry/ | 12-May-2024 | - | 2,905 | 2,683 | ||
| hvigor/ | 12-May-2024 | - | 22 | 22 | ||
| photomodify/ | 12-May-2024 | - | 3,870 | 3,594 | ||
| screenshots/devices/ | 12-May-2024 | - | ||||
| .gitignore | D | 12-May-2024 | 254 | 15 | 14 | |
| README.md | D | 12-May-2024 | 1.9 KiB | 40 | 20 | |
| README_zh.md | D | 12-May-2024 | 7.3 KiB | 110 | 86 | |
| build-profile.json5 | D | 12-May-2024 | 1.1 KiB | 47 | 46 | |
| hvigorfile.js | D | 12-May-2024 | 168 | 2 | 1 | |
| hvigorw | D | 12-May-2024 | 2.1 KiB | 62 | 28 | |
| hvigorw.bat | D | 12-May-2024 | 2 KiB | 72 | 56 | |
| oh-package.json5 | D | 12-May-2024 | 817 | 27 | 25 | |
| ohosTest.md | D | 12-May-2024 | 6.9 KiB | 40 | 38 |
README.md
1# Image Processing 2 3### Introduction 4 5This sample demonstrates the image processing function. 6 7In this sample, [\<TextArea>](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md) is used to implement multi-line text input, [mediaLibrary](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-mediaquery.md) is used to obtain images from albums, [image](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md) is used to generate pixel maps, and **scale()**, **crop()**, and **rotate()** of the **pixelMap** class are used to scale, crop, and rotate images. 8 9### Usage 10 111. Touch **Add image** on the offering review page. The page for selecting images is displayed. 12 132. Select the images to be displayed. You can select six images at most. 14 153. Select an image and touch **Next**. The image editing page is displayed. To scale an image, touch **scale** and then touch **narrow** or **amplification**. To crop the image, touch **crop** and select a crop ratio. To rotate the image, touch **rotate**. 16 174. After finishing editing the image, touch **OK**. The page for posting comments is displayed, with the images shown. You can touch **Add image** to add more images. 18 195. Touch the back button to exit the app. 20 21### Preview 22 23   24 25### Required Permissions 26 27[ohos.permission.READ_MEDIA](https://gitee.com/openharmony/docs/blob/master/en/application-dev/security/permission-list.md), which allows an app to read media files from the user's external storage. 28 29### Dependency 30 31N/A 32 33### Constraints 34 351. This sample can only be run on standard-system devices that use the Rockchip RK3568 chip. 36 372. This sample is based on the stage model, which is supported from API version 10 (API Version 10 Release). 38 393. DevEco Studio (4.0Release) must be used. 40
README_zh.md
1# 图片编辑 2 3### 介绍 4 5本示例使用 [TextArea](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-basic-components-textarea.md) 6实现多文本输入,使用 [@ohos.app.ability.common](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-common.md) 7依赖系统的图库引用,实现在相册中获取图片,使用 [@ohos.multimedia.image](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-image-kit/js-apis-image.md) 8生成pixelMap,使用pixelMap的scale(),crop(),rotate()接口实现对图片的缩放,裁剪,旋转功能。 9使用[@ohos.effectKit](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkgraphics2d/js-apis-effectKit.md) 10生成effectKit,使用effectKit.getHighestSaturationColor() 11接口实现对图片的高亮调节。添加文字/贴纸,利用组件的组合编辑素材大小和位置,再使用OffscreenCanvasRenderingContext2D进行离屏绘制保存。 12 13### 效果预览 14 15| 编辑删除 | 图片调整 | 图片标记 | 16|-------------------------------------------------|-----------------------------------------------------|-------------------------------------------------| 17|  |  |  | 18 19| 图片裁剪 | 图片缩放 | 图片旋转 | 20|-------------------------------------------------|---------------------------------------------------|-----------------------------------------------------| 21|  |  |  | 22 23| 图片亮度调节 | 图片添加贴纸 | 图片添加文字 | 24|-----------------------------------------------------|-------------------------------------------------------|-------------------------------------------------| 25|  |  |  | 26 27使用说明: 28 291. 发表评价页面点击添加图片/照片,页面跳转到图片选择页面; 302. 进入图片选择页面后,选择需要显示的图片; 313. 选中图片后,页面会跳转到发表评价页面,点击图片跳转到图片编辑删除页面,点击编辑进入到编辑功能页; 324. 调整菜单有裁剪、缩放、旋转、调色功能; 335. 标记菜单有添加文字、添加贴纸功能; 346. 编辑完成后,点击撤回按钮图片会还原到上一个编辑状态; 357. 图片编辑完成后,点击保存,页面会跳转到发表评价页面,显示相关照片; 368. 点击返回按钮,退出应用。 37 38### 工程目录 39 40``` 41entry/src/main/ets/ 42|---pages 43| |---EditImages.ets // 图片编辑 44| |---GetPictrues.ets // 图片选择 45| |---Index.ets // 首页 46| |---UpadatePages.ets // 编辑删除界面 47photomodify/src/main/ets/components 48|---featrue 49| |---ComputeFeature.ets // 计算功能 50| |---PixelMapQueue.ets // PixelMap队列 51|---model 52| |---AdjustData.ets // 功能数据 53| |---AdjustModels.ets // 功能模型 54| |---MaterialData.ets // 素材数据 55| |---MaterialModels.ets // 素材模型 56|---pages 57| |---EditImage.ets // 图片编辑 58| |---InputTextDialog.ets // 输入框弹窗 59| |---MaterialEdit.ets // 素材编辑组件 60| |---ScalePhotoPage.ets // 图片缩放 61| |---UpdatePage.ets // 编辑删除界面 62|---util 63| |---CoordinatesUtil.ets // 转换坐标系 64| |---CopyObj.ets // 对象克隆 65| |---ImageUtil.ets // 图片宽高处理 66| |---Logger.ets // 日志工具 67| |---MediaUtil.ts // 媒体帮助类 68| |---SvgUtil.ts // svg操作帮助类 69``` 70 71### 具体实现 72 73+ 图片选择功能在GetPictures中实现,源码参考[GetPictures.ets](entry%2Fsrc%2Fmain%2Fets%2Fpages%2FGetPictures.ets): 74 + 图片选择:首先使用startAbilityForResult()启动系统图库应用,然后将选择的图片用select数组保存路径,展示到页面便于选择,选择完跳转到首页,点击一张图片,进入到编辑删除界面。 75+ 图片编辑功能在EditImage中实现,源码参考[EditImage.ets](photomodify%2Fsrc%2Fmain%2Fets%2Fcomponents%2Fpages%2FEditImage.ets): 76 + 图片编辑:图片编辑权限需要使用[requestPermissionsFromUser](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9) 77 申请,源码参考[MainAbility.ts](entry/src/main/ets/MainAbility/MainAbility.ts) 78 ,首先根据选择图片获取到的uri打开图片文件,fileAsset.open选择‘rw'读写模式,然后使用image.createImageSource创建图片源实例,接下来使用createPixelMap创建PixelMap对象,便于处理图片,最后使用crop对图像进行裁剪处理,使用scale对图像进行缩放处理,rotate进行旋转处理。亮度调节使用effectKit.getHighestSaturationColor() 79 接口实现对图片的高亮调节。添加文字/贴纸,编辑模式下,使用组件组合(Image、Shape、Text)进行交互完成素材大小和位置选择;编辑确认后,再使用OffscreenCanvasRenderingContext2D进行离屏绘制,保存为新的pixelMap。 80 81### 相关权限 82 83[ohos.permission.READ_MEDIA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionread_media) 84 85[ohos.permission.WRITE_MEDIA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionwrite_media) 86 87[ohos.permission.MEDIA_LOCATION](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionmedia_location) 88 89### 依赖 90 91不涉及。 92 93### 约束与限制 94 951. 本示例仅支持标准系统上运行,支持设备:RK3568; 962. 本示例为Stage模型,已适配API version 10版本SDK,SDK版本号(API Version 10 Release),镜像版本号(4.0Release); 973. 本示例需要使用DevEco Studio 版本号(4.0Release)及以上版本才可编译运行。 98 99### 下载 100 101如需单独下载本工程,执行如下命令: 102 103``` 104git init 105git config core.sparsecheckout true 106echo code/BasicFeature/Media/Image/ > .git/info/sparse-checkout 107git remote add origin https://gitee.com/openharmony/applications_app_samples.git 108git pull origin master 109``` 110