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   #安装使用方法
相关推荐
崔小汤呀4 天前
Docker部署Nacos
docker·容器
缓解AI焦虑4 天前
Docker + K8s 部署大模型推理服务:资源划分与多实例调度
docker·容器
1candobetter5 天前
Docker Compose Build 与 Up 的区别:什么时候必须重建镜像
docker·容器·eureka
至此流年莫相忘5 天前
Kubernetes实战篇之配置与存储
云原生·容器·kubernetes
小马爱打代码5 天前
Docker:完全指南从入门到精通
运维·docker·容器
ITKEY_5 天前
docker 容器端口映射消失
docker·容器
倚肆5 天前
windows安装docker(末尾附命令大全)
docker·容器
至此流年莫相忘5 天前
Kubernetes实战篇之服务发现
容器·kubernetes·服务发现
Zaly.6 天前
解决 Windows 下 Docker Desktop 启动失败:从虚拟化报错到成功运行的全流程
windows·docker·容器