[文章]鸿蒙应用开发图片编辑器练习与分享

阅读量0
0
2
`

显示效果:
点击“旋转”
图片2.png
点击“剪裁”
图片3.png
点击“缩放”
图片4.png
点击“镜像”
图片5.png
布局中的代码
<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayout
    xmlns:ohos="http://schemas.huawei.com/res/ohos"
    ohos:height="match_parent"
    ohos:width="match_parent"
    ohos:orientation="vertical">

    <Text
        ohos:height="match_content"
        ohos:width="match_content"
        ohos:layout_alignment="horizontal_center"
        ohos:text="蛟龙腾飞图像开发"
        ohos:text_size="80"
        ohos:top_margin="40vp"
        />

    <DirectionalLayout
        xmlns:ohos="http://schemas.huawei.com/res/ohos"
        ohos:height="match_content"
        ohos:width="match_content"
        ohos:layout_alignment="horizontal_center"
        ohos:orientation="horizontal"
        ohos:top_margin="20vp">

        <Button
            ohos:id="$+id:jltfwhirl_image"
            ohos:height="match_content"
            ohos:width="match_content"
            ohos:background_element="$graphic:jltfbackground_button"
            ohos:padding="12vp"
            ohos:right_margin="5vp"
            ohos:text="旋转"
            ohos:text_size="20vp"
            ohos:top_margin="10vp">
        </Button>

        <Button
            ohos:id="$+id:jltfcrop_image"
            ohos:height="match_content"
            ohos:width="match_content"
            ohos:background_element="$graphic:jltfbackground_button"
            ohos:left_margin="5vp"
            ohos:padding="12vp"
            ohos:text="剪裁"
            ohos:text_size="20vp"
            ohos:top_margin="10vp">
        </Button>

        <Button
            ohos:id="$+id:jltfscale_image"
            ohos:height="match_content"
            ohos:width="match_content"
            ohos:background_element="$graphic:jltfbackground_button"
            ohos:left_margin="5vp"
            ohos:padding="12vp"
            ohos:text="缩放"
            ohos:text_size="20vp"
            ohos:top_margin="10vp">
        </Button>

        <Button
            ohos:id="$+id:jltfmirror_image"
            ohos:height="match_content"
            ohos:width="match_content"
            ohos:background_element="$graphic:jltfbackground_button"
            ohos:left_margin="5vp"
            ohos:padding="12vp"
            ohos:text="镜像"
            ohos:text_size="20vp"
            ohos:top_margin="10vp"/>
    </DirectionalLayout>

    <Image
        ohos:id="$+id:jltfimage"
        ohos:height="1200px"
        ohos:width="1024px"
        ohos:image_src="$media:shici1"
        ohos:layout_alignment="horizontal_center"
        ohos:top_margin="20vp">
    </Image>

</DirectionalLayout>
学习材料:
https://developer.huawei.com/consumer/cn/codelabsPortal/carddetails/HarmonyOS-Image-Operations
完整代码地址:

`
图片1.png

回帖

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容图片侵权或者其他问题,请联系本站作侵删。 侵权投诉
链接复制成功,分享给好友