OpenHarmony图像解码库—stb-image【GN编译】

简介

stb_image主要是C/C++实现的图像解码库。

下载安装

直接在OpenHarmony-SIG仓中搜索stb-image并下载。

使用说明

以OpenHarmony 3.1 Beta的rk3568版本为例

  1. 库代码存放路径:./third_party/stb-image

  2. 修改添加依赖的编译脚本,路径:/developtools/bytrace_standard/ohos.build

    {
    "subsystem": "developtools",
    "parts": {
    "bytrace_standard": {
    "module_list": [
    "//developtools/bytrace_standard/interfaces/innerkits/native:bytrace_core",
    "//developtools/bytrace_standard/bin:bytrace_target",
    "//developtools/bytrace_standard/bin:bytrace.cfg",
    "//developtools/bytrace_standard/interfaces/kits/js/napi:bytrace",
    "//third_party/stb-image:stb_image",
    "//third_party/stb-image:stb_image_test"
    ],
    "inner_kits": [
    {
    "type": "so",
    "name": "//developtools/bytrace_standard/interfaces/innerkits/native:bytrace_core",
    "header": {
    "header_files": [
    "bytrace.h"
    ],
    "header_base": "//developtools/bytrace_standard/interfaces/innerkits/native/include"
    }
    }
    ],
    "test_list": [
    "//developtools/bytrace_standard/bin/test:unittest"
    ]
    }
    }
    }

  3. 用命令 ./build.sh --product-name rk3568 --ccache 编译

  4. 生成库文件路径:out/rk3568/developtools/profiler,该路径会生成库文件

接口说明

  1. 加载图像数据 stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality)

  2. 修改图像尺寸 stbir_resize(const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, stbir_datatype datatype, int num_channels, int alpha_channel, int flags, stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, stbir_filter filter_horizontal, stbir_filter filter_vertical, stbir_colorspace space, void *alloc_context)

  3. 将像素数据写入文件 stbi_write_png(char const *filename, int x, int y, int comp, const void *data, int stride_bytes)

  4. 保存 jpg 格式图片 stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality)

约束与限制

在下述版本验证通过:

DevEco Studio: 3.1Release(3.1.0.200), SDK: API9 Release(3.2.10.6)

目录结构

|---- stb-image   #库的具体实现都在此目录下
|     |---- data   #图片资源
|     |---- deprecated   #弃用代码
|     |---- docs   #文档说明
|     |---- tests   #单元测试用例
|     |---- tools   #工具模块
|     |---- README.md   #安装使用方法
相关推荐
misakivv1 小时前
Centos7.9 使用 Kubeadm 自动化部署 K8S 集群(一个脚本)
运维·云原生·容器·kubernetes·自动化
OH五星上将2 小时前
OpenHarmony(鸿蒙南向开发)——小型系统内核(LiteOS-A)【用户态内存调测】
嵌入式硬件·移动开发·harmonyos·内存管理·openharmony·鸿蒙开发·liteos-a
周湘zx4 小时前
k8s下的网络通信与调度
linux·运维·云原生·容器·kubernetes
qq_339191144 小时前
docker 创建showdoc服务 showdoc容器部署教程
运维·docker·容器
qq_415292645 小时前
docker镜像源
运维·docker·容器
Zww08916 小时前
docker部署excalidraw画图工具
运维·docker·容器
Amd7946 小时前
Nuxt Kit 使用日志记录工具
日志记录·应用开发·nuxt 3·nuxt kit·前端工具·错误调试·uselogger
LCRxxoo7 小时前
windows docker下启动mysql报Bind on unix socket: Input/output error
mysql·docker·容器
职教育人7 小时前
Docker UI强大之处?
spring cloud·docker·容器
OH五星上将8 小时前
OpenHarmony(鸿蒙南向开发)——标准系统方案之瑞芯微RK3568移植案例(上)
harmonyos·鸿蒙系统·openharmony·鸿蒙开发·系统移植·鸿蒙内核·子系统