最后就是调用stbi_write_png方法将像素数据写入文件中,除此之外,stb_image_write 还提供了stbi_write_jpg方法来保存 jpg 格式图片。 根据两者格式的不同,方法调用的参数也是不一样的。 int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality) int stbi_write...
我们会从textures目录载入一个叫做texture.jpg的图像文件。我们使用的图像大小为512x512 像素。这里使用的图像库可以载入常见格式的图像文件, 比如JPEG,PNG,BMP和GIF图像文件。 使用图像库载入文件非常简单: voidcreateTextureImage(){inttexWidth,texHeight,texChannels;stbi_uc*pixels=stbi_load("textures/texture.jpg"...