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: display Album Art in actual size, if smaller than panel (Read 900 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

display Album Art in actual size, if smaller than panel

or, don't expand to fill panel, but if larger, do shrink to fit panel while preserving aspect ratio.

I think that sums it up. Don't see any option for that in v. 2.1.6 [x86]. I'm using Columns UI, which no longer deals with artwork source settings. My recollection is that these options used to exist (pre-v.2).

If there is no such option, any chance it could be implemented?

Thanks.

Re: display Album Art in actual size, if smaller than panel

Reply #1
Pretty sure this has not existed before??

But it can be done with my component (JScript Panel 3, link in signature) and this code pasted in a panel...

Code: [Select]
// ==PREPROCESSOR==
// @name "GetAlbumArtNew"
// @author "marc2003"
// ==/PREPROCESSOR==

// Prefers now playing track if playing, follows playlist selection if not
// Double click panel to view image in fb2k picture viewer

var g_img = null;
var g_metadb = null;
var g_tooltip = window.CreateTooltip('Segoe UI', 16);
g_tooltip.SetMaxWidth(600); // enable multi-line tooltips
g_tooltip.Text = '';
var g_info = '';

var ww = 0, wh = 0;
update_album_art();

function update_album_art() {
if (g_img) {
g_img.Dispose();
g_img = null;
}

g_info = '';
g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();

if (g_metadb) {
g_img = g_metadb.GetAlbumArt(); // omitting the type defaults to front

if (g_img) {
var path = g_img.Path;
g_info = 'Original dimensions: ' + g_img.Width + 'x' + g_img.Height; // add image dimensions to tooltip
if (path.length) g_info += '\nPath: ' + path; // add path on new line if present
}
}

window.Repaint();
}

function on_colours_changed() {
window.Repaint();
}

function on_item_focus_change() {
if (!fb.IsPlaying) {
update_album_art();
}
}

function on_mouse_lbtn_dblclk() {
if (g_metadb) {
g_metadb.ShowAlbumArtViewer(0);
}
}

function on_mouse_move(x, y) {
if (g_info.length && g_tooltip.Text != g_info) {
g_tooltip.Text = g_info;
g_tooltip.Activate();
}
}

function on_paint(gr) {
var bg = window.IsDefaultUI ? window.GetColourDUI(1) : window.GetColourCUI(3);
gr.Clear(bg);

if (g_img) {
var pos_x = 0, pos_y = 0;
var scale = 1;

if (g_img.Width < ww && g_img.Height < wh) {
// image smaller than panel
pos_x = (ww - g_img.Width) / 2;
pos_y = (wh - g_img.Height) / 2;
} else {
// image larger than panel, keep aspect
var scale_w = ww / g_img.Width;
var scale_h = wh / g_img.Height;
scale = Math.min(scale_w, scale_h);

if (scale_w < scale_h)
pos_y = (wh - g_img.height * scale) / 2;
else if (scale_w > scale_h)
pos_x = (ww - g_img.Width * scale) / 2;
}

gr.DrawImage(g_img, pos_x, pos_y, g_img.Width * scale, g_img.Height * scale, 0, 0, g_img.Width, g_img.Height);
}
}

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

// get notified of album art changes when listening to a supported stream
function on_playback_dynamic_info_track(type) {
// type 0 is metadata which we're not interested in
if (type == 1) {
update_album_art();
}
}

function on_playback_new_track() {
update_album_art();
}

function on_playback_stop(reason) {
if (reason != 2) {
update_album_art();
}
}

function on_playlist_switch() {
if (!fb.IsPlaying) {
update_album_art();
}
}

Art larger than panel, it touches the edge like default...



Larger panel...



Re: display Album Art in actual size, if smaller than panel

Reply #3
Oh right, that's a 3rd party component which is why I wasn't aware of this feature existing before. You can still use it with latest fb2k/columns UI if you can find it.

edit: this comment applies to 32bit users only which the OP explicitly mentioned in their first post. 64bit users would have to use my solution.

Re: display Album Art in actual size, if smaller than panel

Reply #4
I have a modded version of the component, and it does work in the 32-bit v2 with latest Columns UI (2.1). I had the DLL under "...AppData\Roaming\foobar2000-v2\user-components\foo_uie_albumart_mod\" (got there during upgrade to v2, I reckon), so the install instructions @

https://wiki.hydrogenaud.io/index.php?title=Foobar2000:Components/Album_Art_Panel_(foo_uie_albumart)
(this link should be properly clickable now; stupid closing ')' ;-)

caused a problem when I copied "foo_uie_albumart_mod.dll" to components under Program Files. The instructions are correct for adding the panel. I just set the stock Columns UI panel ("Artwork view") to Hide, though I guess it can be removed.

One mod I made to the Sources list was to add

-$replace(%path%,%filename_ext%,)%filename%.*

which will pick up art that matches the audio file name. I do this for some things where each song has it's own art. I didn't test using embedded art.

Thanks for the heads up! and the code. I'm sure it will help someone down the line.