-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJPEG.cpp
30 lines (22 loc) · 915 Bytes
/
JPEG.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once
#include "Decoder.h"
int main()
{
clock_t launch = clock();
FILE *fileptr;
unsigned char *buffer;
long fileLen;
int cursor;
unsigned char *imageDecoded;
fileptr = fopen("mom.jpg", "rb"); // Open the file in binary mode
fseek(fileptr, 0, SEEK_END); // Jump to the end of the file
fileLen = ftell(fileptr); // Get the current byte offset in the file
rewind(fileptr); // Jump back to the beginning of the file
buffer = (unsigned char *)malloc((fileLen + 1)*sizeof(unsigned char)); // Enough memory for file + \0
fread(buffer, fileLen, 1, fileptr); // Read in the entire file
cursor = 0;
imageDecoded = DecodeImage(buffer, cursor);
double decodeTime = (double)(clock() - launch) / 1000;
std::cout << "Total elapsed time is: " << decodeTime << " secs." << std::endl;
fclose(fileptr); // Close the file
}