Ahoj,
Ja som na watermarkovanie pouzival 'Sandmark'. Dokonca su k dispoziicii
aj zdrojaky, takze by som si ich stiahol a pozrel ako to robia chlapci tam.
Martin Krajci
Vlastimil Vávrů wrote:
Za boha nemůžu rozchodit průhlednost u kládaného vodoznaku.
Na googlu jsem našel spousty příkladů a vytvořil jsem si následující
statickou metodu:
private static void createWaterMark(BufferedImage img, BufferedImage
watermark, float alpha, float percentSize,
int border) {
int newWatWidth = Math.round(percentSize * img.getWidth());
int newWatHeight = Math.round((newWatWidth / (1.0f *
watermark.getWidth())) * watermark.getHeight());
int watOffsetX = img.getWidth() - newWatWidth - border;
int watOffsetY = img.getHeight() - newWatHeight - border;
BufferedImage resizedThumbnail = new BufferedImage(newWatWidth,
newWatHeight, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics2D = resizedThumbnail.createGraphics();
graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
graphics2D.drawImage(watermark, 0, 0, newWatWidth,
newWatHeight, null);
Graphics2D g = img.createGraphics();
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
alpha));
g.drawImage(resizedThumbnail, watOffsetX, watOffsetY, null);
resizedThumbnail.flush();
g.dispose();
}
klíčová pro průhlednost je řádka
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
alpha));
kde se pomocí AlphaComposite nastavuje způsob interakce barvy původního
pixelu obrázku s barvou pixelu vkládaného obrázku (vodoznaku).
Problém je, že se kýžená průhlednost nedostavuje - průhledné pixely se
zobrazí černou barvou.
Děkuji za rady.
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit
http://www.messagelabs.com/email______________________________________________________________________
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________