Advertisement
nbonneel

Template code image

Jan 7th, 2020
722
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS 1
  2. #include <vector>
  3.  
  4. #define STB_IMAGE_WRITE_IMPLEMENTATION
  5. #include "stb_image_write.h"
  6.  
  7. #define STB_IMAGE_IMPLEMENTATION
  8. #include "stb_image.h"
  9.  
  10.  
  11.  
  12. int main() {
  13.     int W = 512;
  14.     int H = 512;
  15.    
  16.     std::vector<unsigned char> image(W*H * 3, 0);
  17.     for (int i = 0; i < H; i++) {
  18.         for (int j = 0; j < W; j++) {
  19.  
  20.             image[(i*W + j) * 3 + 0] = 255;
  21.             image[(i*W + j) * 3 + 1] = 0;
  22.             image[(i*W + j) * 3 + 2] = 0;
  23.         }
  24.     }
  25.     stbi_write_png("image.png", W, H, 3, &image[0], 0);
  26.  
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement