From 965b6d94f22124518adcda30a128edb8f2c3d97a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ball=C3=B3=20Gy=C3=B6rgy?= Date: Sun, 3 Nov 2024 11:48:10 +0100 Subject: [PATCH] Pass blurred image directly to texture (#307) Instead of saving the blurred image into a temporary file and then read it back, pass it direcly to texture via a buffer. --- cartridges/game_cover.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cartridges/game_cover.py b/cartridges/game_cover.py index e6518f9..44b477c 100644 --- a/cartridges/game_cover.py +++ b/cartridges/game_cover.py @@ -17,6 +17,7 @@ # # SPDX-License-Identifier: GPL-3.0-or-later +from io import BytesIO from pathlib import Path from typing import Optional @@ -83,10 +84,11 @@ class GameCover: .filter(ImageFilter.GaussianBlur(20)) ) - tmp_path = Gio.File.new_tmp(None)[0].get_path() - image.save(tmp_path, "tiff", compression=None) + buffer = BytesIO() + image.save(buffer, "tiff", compression=None) + gbytes = GLib.Bytes.new(buffer.getvalue()) - self.blurred = Gdk.Texture.new_from_filename(tmp_path) + self.blurred = Gdk.Texture.new_from_bytes(gbytes) stat = ImageStat.Stat(image.convert("L"))