rename project in pubspect. testing streamingview.
This commit is contained in:
@ -20,15 +20,44 @@ FILE *make_buffer(const uint8_t *data, const size_t data_len)
|
||||
return file;
|
||||
}
|
||||
|
||||
int read_buffer(FILE *file, uint8_t **buffer, size_t *length) {
|
||||
if (file != NULL) {
|
||||
// Get the file size
|
||||
fseek(file, 0, SEEK_END);
|
||||
(*length) = ftell(file);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
|
||||
const Frame *new_frame_from_data(const uint8_t *data, const size_t data_len, int w, int h, int depth)
|
||||
// Allocate memory
|
||||
*buffer = (uint8_t *) malloc((*length) * sizeof(char));
|
||||
if (buffer == NULL) {
|
||||
printf("Error: Unable to allocate memory.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Read file
|
||||
size_t newLen = fread(*buffer, sizeof(char), *length, file);
|
||||
if (newLen == 0) {
|
||||
if (feof(file)) {
|
||||
printf("Error: End of file reached.\n");
|
||||
return 2;
|
||||
}
|
||||
printf("Error: Reading file.\n");
|
||||
return 3;
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
||||
Frame *new_frame_from_data(const uint8_t *data, const size_t data_len, int w, int h, int depth)
|
||||
{
|
||||
FILE *buf = make_buffer(data, data_len);
|
||||
return new_frame_from_handle(buf, w, h, depth);
|
||||
}
|
||||
|
||||
|
||||
const Frame *new_frame_from_handle(FILE *stream, int w, int h, int depth)
|
||||
Frame *new_frame_from_handle(FILE *stream, int w, int h, int depth)
|
||||
{
|
||||
Frame *f = (Frame *)malloc(sizeof(Frame));
|
||||
f->stream = stream;
|
||||
|
Reference in New Issue
Block a user