fileiopp

File IO ++ or fileiopp serves as a utility that interprets files in ways that I deem useful
Log | Files | Refs | README | LICENSE

tester.c (927B)


      1 /*
      2   File IO ++ teser/example file
      3   "tester.c"
      4   M. Yamanaka
      5   email: myamanaka@live.com
      6   website: csmyamanaka.com
      7   license: MIT (See included "LICENSE" file for details)
      8 */
      9 
     10 #include "bmpfileiopp.h"
     11 
     12 int main(){
     13 
     14   /*
     15     This example creates a simple bitmap file with a very generic pattern and writes it to a file.
     16     This file is then read, and its dimensions and number of channels are printed to stdout.
     17   */
     18   
     19   //write
     20   int n = 3; //number of channels
     21   BMPIS e1 = {400, 600, n, "example1.bmp"}; //example 1
     22   char* dE1 = (char*)malloc(sizeof(char)*400*600*n); //data for e1
     23 
     24   for(int i = 0; i < 400*600*n; i++){
     25     if(i < 200*600*n) dE1[i] = (char)255;
     26     else dE1[i] = (char)0;
     27   }
     28   writeBMP(e1, dE1);
     29 
     30   //read
     31   BMPIS e2 = {0, 0, 0, "example1.bmp"};
     32   char* dE2;
     33   readBMP(&e2, &dE2);
     34   printf("width: %d, height: %d, number of channels: %d\n", e2.w, e2.h, e2.c);
     35 
     36   free(dE1);
     37   free(dE2);
     38   return 0;
     39 }

Generated using stagit (https://codemadness.org/stagit.html)