MCPcopy Create free account
hub / github.com/andysworkshop/stm32plus / countImages

Method countImages

examples/pframe/BitmapManager.cpp:51–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49 */
50
51bool BitmapManager::countImages() {
52
53 char buffer[30];
54 FileInformation *finfo;
55 uint32_t length;
56 FileSystem& fs=_fsManager.getFileSystem();
57
58 _lcdManager.getLcd().setForeground(ColourNames::WHITE);
59
60 // status
61
62 _term.writeString("Counting images");
63
64 // iterate over sequential *.262 images in /pframe/img
65 // e.g. 0.262, 1.262, 2.262 etc.
66
67 _imageCount=0;
68
69 for(;;) {
70
71 // check that the image exists
72
73 strcpy(buffer,"/pframe/img/");
74 StringUtil::itoa(_imageCount,buffer+12,10);
75 strcat(buffer,".262");
76
77 if(!fs.getFileInformation(buffer,finfo))
78 break;
79
80 // verify that this is a bitmap by checking the size
81
82 length=finfo->getLength();
83 delete finfo;
84
85 if(length!=IMAGE_BYTE_SIZE)
86 return error("Invalid image format");
87
88 _imageCount++;
89 _term << '.';
90 }
91
92 _term << '\n';
93
94 // check for no images
95
96 if(_imageCount==0)
97 return error("There are no images to play");
98
99 _term << "Found " << _imageCount << " images\n";
100
101 return true;
102}
103
104
105/*

Callers

nothing calls this directly

Calls 4

itoaFunction · 0.85
getFileInformationMethod · 0.80
writeStringMethod · 0.45
getLengthMethod · 0.45

Tested by

no test coverage detected