I see in the coverArt.jsp there is a section that says
coverArtSize: Height and width of cover art.
But I cant seem to get it to work.
Any advice?
Moderator: moderators
coverArtSize: Height and width of cover art.
<div style="width:${size}; max-width:${size}; height:${size}; max-height:${size}" title="${param.albumName}">
public static BufferedImage scale(BufferedImage image, int width, int height) {
int w = image.getWidth();
int h = image.getHeight();
BufferedImage thumb = image;
// For optimal results, use step by step bilinear resampling - halfing the size at each step.
do {
w /= 2;
h /= 2;
if ((w < width) && (h < height)) {
// The new size fits entirely into the target size
if (1.0*w/width > 1.0*h/height) {
h =(int) (1.0 * h / w * width);
w = width;
} else {
w =(int) (1.0 * w / h * height);
h = height;
}
}
BufferedImage temp = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = temp.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g2.drawImage(thumb, 0, 0, temp.getWidth(), temp.getHeight(), null);
g2.dispose();
thumb = temp;
} while ((w != width)&&(h != height));
return thumb;
}
public static BufferedImage scale(BufferedImage image, int width, int height) {
int w = image.getWidth();
int h = image.getHeight();
float multiplier = 0;
BufferedImage thumb = image;
if (h > height)
{
multiplier = ((float)height / (float)h);
h = height;
w = (int)(w * multiplier);
}
if (w > width)
{
multiplier = ((float)width / (float)w);
w = width;
h = (int)(h * multiplier);
}
BufferedImage temp = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = temp.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g2.drawImage(thumb, 0, 0, temp.getWidth(), temp.getHeight(), null);
g2.dispose();
thumb = temp;
return thumb;
}
scooter1556 wrote:This code should also work and make sure that the image is the maximum size it can be whilst maintaining aspect ratio.
- Code: Select all
public static BufferedImage scale(BufferedImage image, int width, int height) {
int w = image.getWidth();
int h = image.getHeight();
float multiplier = 0;
BufferedImage thumb = image;
if (h > height)
{
multiplier = ((float)height / (float)h);
h = height;
w = (int)(w * multiplier);
}
if (w > width)
{
multiplier = ((float)width / (float)w);
w = width;
h = (int)(h * multiplier);
}
BufferedImage temp = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = temp.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g2.drawImage(thumb, 0, 0, temp.getWidth(), temp.getHeight(), null);
g2.dispose();
thumb = temp;
return thumb;
}
Return to Mods, Apps and Clients
Users browsing this forum: No registered users and 11 guests