-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjpeg_decoder.cpp
32 lines (26 loc) · 1.84 KB
/
jpeg_decoder.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
31
32
// jpeg_decoder.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <vector>
#include "ImgJpeg.h"
uint8_t* ReadAllBytes(const char * inputFile)
{
FILE *fileptr;
uint8_t *buffer;
long filelen;
fopen_s(&fileptr, inputFile, "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 = (uint8_t *)malloc((filelen + 1) * sizeof(uint8_t)); // Enough memory for file + \0
fread(buffer, filelen, 1, fileptr); // Read in the entire file
fclose(fileptr); // Close the file
return buffer;
}
int main()
{
ImgJpeg* _img = new ImgJpeg(ReadAllBytes("C:\\Users\\Julian\\Desktop\\GetFotoAtleta.jpg"));
delete _img;
return 0;
}