Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images.zoomScale 图片缩放,透明背景的png文件自动添加了背景色 #662

Closed
Wizzercn opened this issue May 22, 2014 · 2 comments
Assignees
Milestone

Comments

@Wizzercn
Copy link
Member

求透明背景png文件缩放后还是透明背景

PS:既然有了图片处理类,能否增加图片水印、文字水印的方法,可以设定水印图是否等比缩放,以及水印出现的位置,如左上、右下、中下、中间等。谢~

@ywjno
Copy link
Member

ywjno commented May 22, 2014

public static BufferedImage zoomScale(BufferedImage im, int w, int h)这个方法不会添加背景色

添加图片文字水印自己封装一下不就好了

@Wizzercn
Copy link
Member Author

@ywjno 试过了,zoomScale(BufferedImage im, int w, int h) 是黑色的背景。

自己写了个。。。

BufferedImage nimage = new BufferedImage(nw, nh, BufferedImage.TYPE_INT_RGB);
Graphics2D gc = nimage.createGraphics();
nimage = gc.getDeviceConfiguration().createCompatibleImage(nw, nh, Transparency.TRANSLUCENT);
gc.dispose();
gc = nimage.createGraphics();
gc.fillRect(0, 0, w, h);
gc.setComposite(AlphaComposite.Src);
gc.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
gc.drawImage(markImage, 0, 0, nw, nh, null, null);
gc.dispose();

wendal added a commit that referenced this issue Jun 7, 2015
@wendal wendal closed this as completed Jun 29, 2015
@wendal wendal self-assigned this Jun 29, 2015
@wendal wendal added this to the 1.b.53 milestone Jun 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants