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   #安装使用方法
相关推荐
---wzy---2 小时前
docker生命周期
java·docker·容器
@t.t.3 小时前
使用Swarm工具搭建docker集群
docker·微服务·容器
局外人LZ4 小时前
Docker轻松搭建Neo4j+APOC环境
docker·容器·neo4j
唐可盐14 小时前
解决docker运行zentao 报错:ln: failed to create symbolic link ‘/opt/zbox/tmp/mysq
运维·docker·容器
泯泷18 小时前
编写 Dockerfile:从入门到精通
后端·docker·容器
苏近之20 小时前
微服务版Hello World之k8s集群部署
运维·微服务·容器
HalukiSan1 天前
Docker_Desktop开启k8s
docker·容器
❀͜͡傀儡师1 天前
完成一个可交互的k8s管理平台的页面开发
容器·kubernetes·交互
毒爪的小新1 天前
Docker基础命令
linux·运维·docker·容器·centos
David爱编程1 天前
彻底搞懂容器启动、停止、调试的每一个细节!
后端·docker·容器