add solution of lab 4

This commit is contained in:
2025-02-19 12:06:24 -05:00
parent e902f0662c
commit f4f4f7b138
6 changed files with 337 additions and 2 deletions

View File

@@ -66,6 +66,12 @@ std::vector<uint8_t> extractGifHeader(const std::vector<uint8_t>& fileData) {
// check point 1: complete this function, so as to reverse vector without using iterators.
void reverseFrames(std::vector<GifFrame>& frames) {
size_t n = frames.size();
for (size_t i = 0; i < n / 2; ++i) {
GifFrame temp = frames[i];
frames[i] = frames[n - 1 - i];
frames[n - 1 - i] = temp;
}
}
void writeGif(const std::string& outputFilename, const std::vector<uint8_t>& originalFileData,
@@ -273,7 +279,7 @@ std::vector<GifFrame> extractFrames(const std::string& filename, std::vector<uin
int main() {
// read the complete file into fileData, and extract frames.
std::vector<uint8_t> fileData;
std::vector<GifFrame> frames = extractFrames("input.gif", fileData, loopExtension);
std::vector<GifFrame> frames = extractFrames("brick_fake.gif", fileData, loopExtension);
if (frames.empty()) return 1;
// extract the complete header from fileData