1

I noticed that when trying to draw a square with a black border for BufferedImage graphics it works fine if it is instantiated as TYPE_INT_RGB but it deforms if the BufferedImage was made as TYPE_INT_ARGB seemingly only putting the border on the left and top of the square.

icon = new BufferedImage((int) width, (int) height, BufferedImage.TYPE_INT_ARGB); Graphics2D g = icon.createGraphics(); g.setColor(Color.yellow); g.fillRect(0, 0, (int) this.width-1, (int) this.height-1); g.setColor(Color.BLACK); g.drawRect(0, 0, (int) this.width, (int) this.height); g.dispose(); 

If you try it and get rid of the A in TYPE_INT_ARGB you see what I mean. It is no problem with the squares but it becomes one when I draw circles. In fact, it looks like it is drawing the contents further down and to the left then it does as TYPE_INT_RGB.

Screen shot showing the problem

2
  • Are you running this code on a Windows operating system with a screen scaling > 100%? Commented Oct 23, 2024 at 12:57
  • I took the liberty to update the question with a screenshot that demonstrates the issue. There is clearly a difference. Commented Oct 24, 2024 at 13:55

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.