Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Sharper resampling of album art? (Read 3132 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

Sharper resampling of album art?

Album Art displayed in Foobar's default user interface isn't as sharp as that produced in other applications. My artwork is between 600 and 1000 pixels. It's not optimal to make it any fixed size, so resampling must be used. It seems that bigger artwork gets blurred more.

I don't know if this problem is somehow caused by Windows XP if Foobar relies on it for image processing. I have loaded the latest Foobar version 1.3.8.

Here is a comparison between Foobar, Winamp and IrfanView (straight "fast" resize without any additional sharpening).

Sharper resampling of album art?

Reply #1
you could try replacing the panel with WSH panel mod. there is a sample artwork script included with it inside the samples folder. look inside the on_paint function and find this line of code...

Code: [Select]
gr.DrawImage(g_img, pos_x, pos_y, g_img.Width * scale, g_img.Height * scale, 0, 0, g_img.Width, g_img.Height);


now add this line of code just before it...

Code: [Select]
gr.SetInterpolationMode(7);


other values if you're interested....
Code: [Select]
// Used in SetInterpolationMode()
// For more information, see: http://msdn.microsoft.com/en-us/library/ms534141(VS.85).aspx
InterpolationMode = {
    Invalid: -1,
    Default: 0,
    LowQuality: 1,
    HighQuality: 2,
    Bilinear: 3,
    Bicubic: 4,
    NearestNeighbor: 5,
    HighQualityBilinear: 6,
    HighQualityBicubic: 7
};



Sharper resampling of album art?

Reply #2
This component has a steep learning curve! I don't know any JavaScript.

I loaded GetAlbumArtAsync.txt and found that gr.SetInterpolationMode(); didn't make any difference. I tried all values.

By default the picture is sharper, and is okay. I can see where I can enter the background color to be blue instead of white.

The artwork appears to be resized together with the white background as part of the picture: currently the picture has a white 1/3 pixel border because of that.

http://i.imgur.com/GxnyPyt.png

Sharper resampling of album art?

Reply #3
this version uses the default UI background colour and automatically updates if you change the colour settings. also, it crops the image without stretching so there shouldn't be any gaps. lastly, it even trims the edges by 5 pixels for some images that aren't quite perfect.

Code: [Select]
var prefer_now_playing = true; //prefers now playing track if playing, follows selection if not playing. if false, always follow selection
var id = 0; //0 front 1 back 2 disc 3 icon 4 artist
////////////////////////////////////////////////////////////////////////////////
var g_img = null;
var ww = 0, wh = 0;

function on_colors_changed() {
bg = window.GetColorDUI(1);
window.Repaint();
}
on_colors_changed();
on_item_focus_change();

function on_size() {
ww = window.Width;
wh = window.Height;
}

function on_paint(gr) {
gr.FillSolidRect(0, 0, ww, wh, bg);
if (g_img) {
if (g_img.Width / g_img.Height < ww / wh) {
var dst_w = g_img.Width;
var dst_h = wh * g_img.Width / ww;
var dst_x = 0;
var dst_y = Math.round((g_img.Height - dst_h) / 2);
} else {
var dst_w = ww * img.Height / wh;
var dst_h = g_img.Height;
var dst_x = Math.round((g_img.Width - dst_w) / 2);
var dst_y = 0;
}
gr.SetInterpolationMode(7);
gr.DrawImage(g_img, 0, 0, ww, wh, dst_x + 5, dst_y + 5, dst_w - 10, dst_h - 10);
}
}

function on_item_focus_change() {
var metadb = prefer_now_playing && fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
if (metadb) {
g_img && g_img.Dispose();
g_img = utils.GetAlbumArtV2(metadb, id);
metadb.Dispose();
window.Repaint();
}
}

function on_playback_new_track() {
on_item_focus_change();
}

function on_playback_stop() {
on_item_focus_change();
}

function on_playlist_switch() {
on_item_focus_change();
}

Sharper resampling of album art?

Reply #4
This component has a steep learning curve! I don't know any JavaScript.


Welcome to the club 
In no way I want to stop you from learning javascript, WSH panelmod is a really great component and I'm trying to learn javascript as well, but until I do I found some relief with the panel stack splitter component. The image functions can draw very sharp pictures.
I'm late