added:tests/image_write_test.c+50 added
1+#define STB_IMAGE_WRITE_IMPLEMENTATION2+#include "stb_image_write.h"3+4+// using an 'F' since it has no rotational symmetries, and 6x55+// because it's a small, atypical size likely to trigger edge cases.6+//7+// conveniently, it's also small enough to fully fit inside a typical8+// directory listing thumbnail, which simplifies checking at a glance.9+static const char img6x5_template[] =10+ ".****."11+ ".*...."12+ ".***.."13+ ".*...."14+ ".*....";15+16+int main(int argc, char **argv)17+{18+ // make a RGB version of the template image19+ // use red on blue to detect R<->B swaps20+ unsigned char img6x5_rgb[6*5*3];21+ float img6x5_rgbf[6*5*3];22+ int i;23+24+ for (i = 0; i < 6*5; i++) {25+ int on = img6x5_template[i] == '*';26+ img6x5_rgb[i*3 + 0] = on ? 255 : 0;27+ img6x5_rgb[i*3 + 1] = 0;28+ img6x5_rgb[i*3 + 2] = on ? 0 : 255;29+30+ img6x5_rgbf[i*3 + 0] = on ? 1.0f : 0.0f;31+ img6x5_rgbf[i*3 + 1] = 0.0f;32+ img6x5_rgbf[i*3 + 2] = on ? 0.0f : 1.0f;33+ }34+35+ stbi_write_png("wr6x5_regular.png", 6, 5, 3, img6x5_rgb, 6*3);36+ stbi_write_bmp("wr6x5_regular.bmp", 6, 5, 3, img6x5_rgb);37+ stbi_write_tga("wr6x5_regular.tga", 6, 5, 3, img6x5_rgb);38+ stbi_write_jpg("wr6x5_regular.jpg", 6, 5, 3, img6x5_rgb, 95);39+ stbi_write_hdr("wr6x5_regular.hdr", 6, 5, 3, img6x5_rgbf);40+41+ stbi_flip_vertically_on_write(1);42+43+ stbi_write_png("wr6x5_flip.png", 6, 5, 3, img6x5_rgb, 6*3);44+ stbi_write_bmp("wr6x5_flip.bmp", 6, 5, 3, img6x5_rgb);45+ stbi_write_tga("wr6x5_flip.tga", 6, 5, 3, img6x5_rgb);46+ stbi_write_jpg("wr6x5_flip.jpg", 6, 5, 3, img6x5_rgb, 95);47+ stbi_write_hdr("wr6x5_flip.hdr", 6, 5, 3, img6x5_rgbf);48+49+ return 0;50+}