stb-image 正在参加 2021 年度 OSC 中国开源项目评选,请投票支持!
stb-image 在 2021 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
2021 年度 OSC 中国开源项目评选 正在火热进行中,快来投票支持你喜欢的开源项目!
2021 年度 OSC 中国开源项目评选 >>> 中场回顾
stb-image 获得 2021 年度 OSC 中国开源项目评选「最佳人气项目」 !
授权协议 MIT
开发语言 C/C++ 查看源码 »
操作系统 跨平台
软件类型 开源软件
开源组织
地区 不详
投 递 者 乌合之众
适用人群 未知
收录时间 2018-03-13

软件简介

C 语言开发的一个简单易用的图像读取解析库,也是 Duilib 上用到的图像解析库。

使用示例代码如下:

#include <stdio.h>

#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"

#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"

int main(int argc, char** argv)
{
    int w, h, n;

    //rgba
    //load image
    unsigned char *data = stbi_load("rgba.png", &w, &h, &n, 0);

    printf("%d, %d, %d\n", w, h, n);

    //change pixel

    //rgba,write 10 red pixel at line 11
    for (int dx = 0; dx < 10; ++dx)
    {
        data[n * w * 10 + dx * n + 0] = 255;
        data[n * w * 10 + dx * n + 1] = 0;
        data[n * w * 10 + dx * n + 2] = 0;
        data[n * w * 10 + dx * n + 3] = 255;
    }
    

    //write image
    stbi_write_png("write.png", w, h, n, data, w * 4);

    stbi_image_free(data);


    return 0;
}

开源协议是 public domain 和 MIT。

展开阅读全文

代码

的 Gitee 指数为
超过 的项目

评论

点击引领话题📣 发布并加入讨论🔥
暂无内容
发表了博客
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
发表了问答
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
暂无内容
0 评论
6 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部