Corrected images alpha channel rendering

This commit is contained in:
luc 2015-10-30 05:18:16 +01:00
parent 2895ab552a
commit aa70ff4ff6
3 changed files with 5 additions and 5 deletions

View File

@ -328,7 +328,7 @@ public class ViewImage {
}
// make a BufferedImage out of that
final BufferedImage i = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
final BufferedImage i = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
try {
i.createGraphics().drawImage(scaled, 0, 0, width, height, null);
image = i;
@ -355,14 +355,14 @@ public class ViewImage {
*/
protected static Image makeSquare(Image image, final int h, final int w) {
if (w > h) {
final BufferedImage dst = new BufferedImage(h, h, BufferedImage.TYPE_INT_RGB);
final BufferedImage dst = new BufferedImage(h, h, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = dst.createGraphics();
final int offset = (w - h) / 2;
g.drawImage(image, 0, 0, h - 1, h - 1, offset, 0, h + offset, h - 1, null);
g.dispose();
image = dst;
} else {
final BufferedImage dst = new BufferedImage(w, w, BufferedImage.TYPE_INT_RGB);
final BufferedImage dst = new BufferedImage(w, w, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = dst.createGraphics();
final int offset = (h - w) / 2;
g.drawImage(image, 0, 0, w - 1, w - 1, 0, offset, w - 1, w + offset, null);

View File

@ -866,7 +866,7 @@ public class YaCyDefaultServlet extends HttpServlet {
if (height < 0) {
height = 96; // bad hack
}
final BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
final BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
bi.createGraphics().drawImage(i, 0, 0, width, height, null);
result = RasterPlotter.exportImage(bi, targetExt);
}

View File

@ -78,7 +78,7 @@ public class EncodedImage {
if (height < 0) {
height = 96; // bad hack
}
final BufferedImage sourceImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
final BufferedImage sourceImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
sourceImage.createGraphics().drawImage(i, 0, 0, width, height, null);
this.image = RasterPlotter.exportImage(sourceImage, targetExt);
}