arFileGrabber.cpp
Go to the documentation of this file.
1 
2 
3 #include "arFileGrabber.h"
4 
5 #include <windows.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 
9 
10 ARFileGrabber::ARFileGrabber(const char* nFileName, int nWidth, int nHeight, int nByterPerComp)
11 {
12  width=nWidth;
13  height=nHeight;
14  bufferlen = nByterPerComp*width*height;
15  buffer = new unsigned char[bufferlen];
16 
17  filename = new char[strlen(nFileName)+1];
18  strcpy(filename, nFileName);
19 
20  fileIdx = 0;
21  oldIdx = -1;
22  showedWarning = false;
23 }
24 
25 
27 {
28  delete buffer;
29 }
30 
31 
32 void
34 {
35  char fname[MAX_PATH];
36 
37  sprintf(fname, filename, fileIdx);
38 
39  FILE* fp = fopen(fname, "rb");
40 
41  if(!fp)
42  {
43  if(!showedWarning)
44  printf("ERROR: can not load file: '%s'\n", fname);
45  showedWarning = true;
46  return;
47  }
48 
49  fread(buffer, 1, bufferlen, fp);
50  fclose(fp);
51 
52  if(fileIdx!=oldIdx)
53  {
54  printf("reading file %s\n", fname);
56  }
57 }
58 
59 
60 void
62 {
63  fileIdx++;
64  //printf("setting fileIdx to %d\n", fileIdx);
65  showedWarning = false;
66 }
unsigned char * buffer
Definition: arFileGrabber.h:33
ARFileGrabber(const char *nFileName, int nWidth=320, int nHeight=240, int nByterPerComp=4)
#define MAX_PATH
Definition: config.h:224
virtual ~ARFileGrabber()


tuw_artoolkitplus
Author(s): Markus Bader
autogenerated on Sun Sep 4 2016 03:24:33