I changed the cursor Icon whenever a certain toggle button is clicked. But the loaded image contains an extra pixel in it at the bottom corner! It's annoying, like there's constant dirt on the screen. I created the cursor icon using junior icon editor. When I open the picture using windows photo viewer or photoshop, the pixel doesn't manifest itself. It only shows when I use it in the application.
The application is a Java application, and this is how I set the cursor.
Image img = getResourceMap().getImageIcon( iconFilename ).getImage();
Cursor newCursor = Toolkit.getDefaultToolkit().createCustomCursor( img,
new Point( 5, 5 ), "cursor" );
Does anyone know what could be the possible reasons for this extra shaded pixel? It occurs right below the east-facing arrow, about 2 milimeters below it.
You can see the effect running this code. The image appears as expected in a label, but as a pointer there is a darkened pixel on the lower left.
import java.awt.*;
import java.awt.image.BufferedImage;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.imageio.ImageIO;
import java.net.URL;
class ShowImage {
public static void main(String[] args) throws Exception {
URL url = new URL("https://i.stack.imgur.com/kP1jv.png");
final BufferedImage img = ImageIO.read(url);
System.out.println(
"Image is: " + img.getWidth() + "x" + img.getHeight());
SwingUtilities.invokeLater( new Runnable() {
public void run() {
JLabel l = new JLabel(new ImageIcon(img));
l.setBorder(new EmptyBorder(5,5,5,5));
l.setOpaque(true);
l.setBackground(Color.GREEN.darker());
Cursor newCursor = Toolkit.getDefaultToolkit().
createCustomCursor( img,new Point( 5, 5 ), "c" );
l.setCursor(newCursor);
JOptionPane.showMessageDialog(null, l);
}
});
}
}