英文:
Grapchis 2D draw image changing color of Image
问题
我正在尝试将不同的图像附加到一张图像上。这一步已经完成,但在附加后,图像的颜色发生了变化。以下是我的现有代码:
BufferedImage baseImg = getBaseImage(src);
Graphics2D g = baseImg.createGraphics();
BufferedImage bmg = getBufferedImageFromSrc(path);
String[] coords = coord.split(",");
g.drawImage((Image)bmg,(int) Double.parseDouble(coords[0]),(int) Double.parseDouble(coords[1]), 60,60,Color.white,null);
g.dispose();
String path = "C://resources/temp.jpeg";
ImageIO.write(baseImg, "jpeg", new File(path));
我能够在指定的坐标上将图像添加到基础图像上,但基础图像的颜色发生了变化。
提前感谢。
英文:
I am trying to attach different images into a image. This is happening but after attaching the color of the image changes. Here is my existing code
BufferedImage baseImg = getBaseImage(src);
Graphics2D g = baseImg.createGraphics();
BufferedImage bmg = getBufferedImageFromSrc(path);
String[] coords = coord.split(",");
g.drawImage((Image)bmg,(int) Double.parseDouble(coords[0]),(int) Double.parseDouble(coords[1]), 60,60,Color.white,null);
g.dispose();
String path = "C://resources/temp.jpeg";
ImageIO.write(bimg, "jpeg", new File(path));
i am able to add the image to the base image at the specified co-ordinates but the base image colour is getting changed.
Here is a sample image
Thanks in advance
专注分享java语言的经验与见解,让所有开发者获益!
评论