arFileGrabber.cpp
Go to the documentation of this file.
00001 
00002 
00003 #include "arFileGrabber.h"
00004 
00005 #include <windows.h>
00006 #include <stdio.h>
00007 #include <stdlib.h>
00008 
00009 
00010 ARFileGrabber::ARFileGrabber(const char* nFileName, int nWidth, int nHeight, int nByterPerComp)
00011 {
00012         width=nWidth;
00013         height=nHeight;
00014         bufferlen = nByterPerComp*width*height;
00015         buffer = new unsigned char[bufferlen];
00016 
00017         filename = new char[strlen(nFileName)+1];
00018         strcpy(filename, nFileName);
00019 
00020         fileIdx = 0;
00021         oldIdx = -1;
00022         showedWarning = false;
00023 }
00024 
00025 
00026 ARFileGrabber::~ARFileGrabber()
00027 {
00028         delete buffer;
00029 }
00030 
00031 
00032 void
00033 ARFileGrabber::GrabFrame()
00034 {
00035         char fname[MAX_PATH];
00036 
00037         sprintf(fname, filename, fileIdx);
00038 
00039         FILE* fp = fopen(fname, "rb");
00040 
00041         if(!fp)
00042         {
00043                 if(!showedWarning)
00044                         printf("ERROR: can not load file: '%s'\n", fname);
00045                 showedWarning = true;
00046                 return;
00047         }
00048 
00049         fread(buffer, 1, bufferlen, fp);
00050         fclose(fp);
00051 
00052         if(fileIdx!=oldIdx)
00053         {
00054                 printf("reading file %s\n", fname);
00055                 oldIdx=fileIdx;
00056         }
00057 }
00058 
00059 
00060 void
00061 ARFileGrabber::NextFile()
00062 {
00063         fileIdx++;
00064         //printf("setting fileIdx to %d\n", fileIdx);
00065         showedWarning = false;
00066 }


tuw_artoolkitplus
Author(s): Markus Bader
autogenerated on Sun May 29 2016 02:50:12