
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#line 5 "biftest.ctr"


#include "dk.h"
#include "dkbif.h"

void run_for_name(char *s)
{
  dk_bif_ptr bptr;
  FILE *f;
  unsigned long w, h, x, y;
  
  bptr = dkbif_open();
  if(bptr) {		
    f = dksf_fopen(s, "rb");
    if(f) {				
      if(dkbif_read_header(bptr, f, s, DKBIF_TYPE_UNKNOWN)) {
        
        if(dkbif_read_data(bptr, f)) {	
	  h = dkbif_get_height(bptr);
	  w = dkbif_get_width(bptr);
	  printf("w = %lu\n", w);
	  printf("h = %lu\n", h);
	  for(y = 0UL; y < h; y++) {
	    for(x = 0UL; x < w; x++) {
	      printf("[ %5lu, %5lu ]   r = %5u   g = %5u   b = %5u   a = %5u\n", x, y, dkbif_get_red(bptr,x,y), dkbif_get_green(bptr,x,y), dkbif_get_blue(bptr,x,y), dkbif_get_alpha(bptr,x,y));
	    }
	  }
	} else {	
	}
      } else {		
      }
      fclose(f); f = NULL;
    } else {				
    }
    dkbif_close(bptr);
  } else {		
  }
  
}


int main(int argc, char *argv[])
{
  
#line 48 "biftest.ctr"

  
  if(argc > 1) {
    run_for_name(argv[1]);
  }
  
  
#line 54 "biftest.ctr"

  exit(0); return 0;
}


