aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/AsyncImageLoader.cpp6
-rw-r--r--src/Body.cpp10
2 files changed, 6 insertions, 10 deletions
diff --git a/src/AsyncImageLoader.cpp b/src/AsyncImageLoader.cpp
index 05c6a7e..ec9ae9a 100644
--- a/src/AsyncImageLoader.cpp
+++ b/src/AsyncImageLoader.cpp
@@ -37,6 +37,8 @@ namespace QuickMedia {
int scaled_y_start = ((float)y / (float)destination_size.y) * source_size.y;
int scaled_x_end = ((float)(x + 1) / (float)destination_size.x) * source_size.x;
int scaled_y_end = ((float)(y + 1) / (float)destination_size.y) * source_size.y;
+ if(scaled_x_end > (int)source_size.x) scaled_x_end = source_size.x;
+ if(scaled_y_end > (int)source_size.y) scaled_y_end = source_size.y;
//float scaled_x = x * width_ratio;
//float scaled_y = y * height_ratio;
@@ -90,9 +92,7 @@ namespace QuickMedia {
}
static void create_thumbnail_if_thumbnail_smaller_than_image(const std::string &original_url, const Path &thumbnail_path, ThumbnailData *thumbnail_data, sf::Vector2i resize_target_size) {
- sf::Vector2u new_image_size = to_vec2u(
- clamp_to_size(
- to_vec2f(thumbnail_data->image->getSize()), to_vec2f(resize_target_size)));
+ sf::Vector2u new_image_size = clamp_to_size(thumbnail_data->image->getSize(), sf::Vector2u(resize_target_size.x, resize_target_size.y));
if(new_image_size.x < thumbnail_data->image->getSize().x || new_image_size.y < thumbnail_data->image->getSize().y) {
auto destination_image = std::make_unique<sf::Image>();
copy_resize(*thumbnail_data->image, *destination_image, new_image_size);
diff --git a/src/Body.cpp b/src/Body.cpp
index a7d772b..fd29d17 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -759,17 +759,13 @@ namespace QuickMedia {
if(load_texture) {
item_thumbnail->referenced = true;
- if(!item->thumbnail_url.empty() && item_thumbnail->loading_state == LoadingState::NOT_LOADED) {
- sf::Vector2i resize_size = thumbnail_resize_target_size;
- if(item->thumbnail_size.x > 0 && item->thumbnail_size.y > 0)
- resize_size = item->thumbnail_size;
- async_image_loader.load_thumbnail(item->thumbnail_url, item->thumbnail_is_local, resize_size, program->is_tor_enabled(), item_thumbnail);
- }
+ if(!item->thumbnail_url.empty() && item_thumbnail->loading_state == LoadingState::NOT_LOADED)
+ async_image_loader.load_thumbnail(item->thumbnail_url, item->thumbnail_is_local, content_size, program->is_tor_enabled(), item_thumbnail);
if(item_thumbnail->loading_state == LoadingState::FINISHED_LOADING && item_thumbnail->image->getSize().x > 0 && item_thumbnail->image->getSize().y > 0) {
if(!item_thumbnail->texture.loadFromImage(*item_thumbnail->image))
fprintf(stderr, "Warning: failed to load texture from image: %s\n", item->thumbnail_url.c_str());
- //item_thumbnail->texture.setSmooth(true);
+ item_thumbnail->texture.setSmooth(true);
//item_thumbnail->texture.generateMipmap();
item_thumbnail->image.reset();
item_thumbnail->loading_state = LoadingState::APPLIED_TO_TEXTURE;