rind: Scale artwork when the sidebar position is changed
I always scale from the original reference image, and never from the displayed pixbuf. This avoids artifacts due to lossy scaling algorithms. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
d2c71f83a8
commit
0b334ddbee
|
@ -555,7 +555,7 @@ audio-volume-medium-symbolic</property>
|
|||
</object>
|
||||
<packing>
|
||||
<property name="resize">False</property>
|
||||
<property name="shrink">False</property>
|
||||
<property name="shrink">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
|
|
@ -11,9 +11,10 @@ def reset():
|
|||
Image.hide()
|
||||
Separator.hide()
|
||||
|
||||
def scale_image(new_w):
|
||||
new_h = (Pixbuf.get_height() * new_w) / Pixbuf.get_width()
|
||||
return Pixbuf.scale_simple(new_w, new_h, GdkPixbuf.InterpType.HYPER)
|
||||
def resize(*args):
|
||||
if Pixbuf != None:
|
||||
set_scaled_image()
|
||||
Paned.connect_after("notify::position", resize)
|
||||
|
||||
def set_image(data):
|
||||
global Pixbuf
|
||||
|
@ -23,6 +24,13 @@ def set_image(data):
|
|||
Pixbuf = loader.get_pixbuf()
|
||||
loader.close()
|
||||
|
||||
Image.set_from_pixbuf(scale_image(Paned.get_position() - 1))
|
||||
set_scaled_image()
|
||||
Image.show()
|
||||
Separator.show()
|
||||
|
||||
def set_scaled_image():
|
||||
new_w = Paned.get_position()
|
||||
new_h = (Pixbuf.get_height() * new_w) / Pixbuf.get_width()
|
||||
if new_h > 0:
|
||||
pix = Pixbuf.scale_simple(new_w, new_h, GdkPixbuf.InterpType.BILINEAR)
|
||||
Image.set_from_pixbuf(pix)
|
||||
|
|
|
@ -34,9 +34,23 @@ class TestAudioArtwork(unittest.TestCase):
|
|||
self.assertEqual(artwork.Pixbuf.get_width(), 512)
|
||||
|
||||
pbuf = artwork.Image.get_pixbuf()
|
||||
self.assertEqual(pbuf.get_height(), 149)
|
||||
self.assertEqual(pbuf.get_width(), 149)
|
||||
self.assertEqual(pbuf.get_height(), 150)
|
||||
self.assertEqual(pbuf.get_width(), 150)
|
||||
|
||||
playbin.set_uri(test_track)
|
||||
self.assertFalse(artwork.Image.is_visible())
|
||||
self.assertFalse(artwork.Separator.is_visible())
|
||||
|
||||
def test_artwork_resize(self):
|
||||
artwork.Paned.set_position(150)
|
||||
playbin.set_uri(test_track, Gst.State.PAUSED)
|
||||
gtk.main_loop(delay=0.1)
|
||||
|
||||
pbuf = artwork.Image.get_pixbuf()
|
||||
self.assertEqual(pbuf.get_height(), 150)
|
||||
self.assertEqual(pbuf.get_width(), 150)
|
||||
|
||||
artwork.Paned.set_position(140)
|
||||
pbuf = artwork.Image.get_pixbuf()
|
||||
self.assertEqual(pbuf.get_height(), 140)
|
||||
self.assertEqual(pbuf.get_width(), 140)
|
||||
|
|
Loading…
Reference in New Issue