Code: Select all
u64* pixels = (u64 *) malloc(sizeof (u64) * height * width);
if (!pixels) {
perror("[Error] Unable to allocate image");
return -1;
}
Image img = {};
img.Height = height;
img.Width = width;
img.Pixels = pixels;
for (u64 i = 0; i < height; i++) {
for (u64 j = 0; j < width; j++) {
pixels[i * width + j] = 0xff818181;
}
}
ExportImageBMP(img, "output.bmp");
Code: Select all
i64 ExportImageBMP(const Image &img, const char *filename) {
return stbi_write_bmp(filename, img.Width, img.Height, 4, img.Pixels);
}

Der Code wird auf WSL mit g++ (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 und stb_image_write kompiliert (https://github.com/nothings/stb/blob/f1 ... ge_write.h)
Mobile version