From 1cacf7d830e44a2e153ae9f15589666b5153e9b5 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 12 Feb 2017 20:03:21 +0100 Subject: [PATCH] Fix so one can use images with other resolutions than 1280x720. --- image_input.cpp | 7 ++++--- image_input.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/image_input.cpp b/image_input.cpp index 9f474c9..a224af9 100644 --- a/image_input.cpp +++ b/image_input.cpp @@ -70,7 +70,7 @@ string search_for_file(const string &filename) ImageInput::ImageInput(const string &filename) : movit::FlatInput({movit::COLORSPACE_sRGB, movit::GAMMA_sRGB}, movit::FORMAT_RGBA_POSTMULTIPLIED_ALPHA, - GL_UNSIGNED_BYTE, 1280, 720), // FIXME + GL_UNSIGNED_BYTE, 1280, 720), // Resolution will be overwritten. filename(filename), pathname(search_for_file(filename)), current_image(load_image(filename, pathname)) @@ -79,6 +79,8 @@ ImageInput::ImageInput(const string &filename) fprintf(stderr, "Couldn't load image, exiting.\n"); exit(1); } + set_width(current_image->width); + set_height(current_image->height); set_pixel_data(current_image->pixels.get()); } @@ -206,7 +208,6 @@ shared_ptr ImageInput::load_image_raw(const string &pat return nullptr; } - // TODO: Scale down if needed! uint8_t *pic_data[4] = {nullptr}; unique_ptr pic_data_cleanup( &pic_data[0], av_freep); @@ -230,7 +231,7 @@ shared_ptr ImageInput::load_image_raw(const string &pat unique_ptr image_data(new uint8_t[len]); av_image_copy_to_buffer(image_data.get(), len, pic_data, linesizes, AV_PIX_FMT_RGBA, frame->width, frame->height, 1); - shared_ptr image(new Image{move(image_data), last_modified}); + shared_ptr image(new Image{unsigned(frame->width), unsigned(frame->height), move(image_data), last_modified}); return image; } diff --git a/image_input.h b/image_input.h index 437d9c2..df25a9f 100644 --- a/image_input.h +++ b/image_input.h @@ -25,6 +25,7 @@ public: private: struct Image { + unsigned width, height; std::unique_ptr pixels; timespec last_modified; }; -- 2.39.2