Bonjour à tous,
je cherche à rendre transparant les pixels qui sont en pur bleue sur mon
image, comment puis-je faire ?
J'arrive à charger une image (png ou gif) dans mon panel, et je voudrais
rendre les pixels bleu transparants...
Button loadButton = new Button("Load...");
loadButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
FileDialog fd = new FileDialog(ju2.this);
fd.show();
if (fd.getFile() == null) return;
String path = fd.getDirectory() + fd.getFile();
loadImage(path);
}
});
// Add the user controls at the bottom of the window.
mControlPanel = new Panel();
mControlPanel.add(loadButton);
add(mControlPanel, BorderLayout.SOUTH);
// Terminate the application if the user closes the window.
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dispose();
System.exit(0);
}
});
}
/*-----------------------------------------------------------
* METHODE
-----------------------------------------------------------*/
private void adjustToImageSize() {
if (!isDisplayable()) addNotify(); // Do this to get valid Insets.
Insets insets = getInsets();
int w = mBufferedImage.getWidth() + insets.left + insets.right;
int h = mBufferedImage.getHeight() + insets.top + insets.bottom;
h += mControlPanel.getPreferredSize().height;
setSize(w, h);
}
/*-----------------------------------------------------------
* METHODE
-----------------------------------------------------------*/
private void center() {
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
Dimension d = getSize();
int x = (screen.width - d.width) / 2;
int y = (screen.height - d.height) / 2;
setLocation(x, y);
}
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Vincent Cantin
mBufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB);
Si tu veux avoir de la transparence, alors il te faut un alpha channel dans ton image. TYPE_INT_RGBA .. et utilise un logiciel d'imagerie pour editer l'alpha channel dans ton image avant de la charger dans ton programme.
mBufferedImage = new BufferedImage(image.getWidth(null),
image.getHeight(null), BufferedImage.TYPE_INT_RGB);
Si tu veux avoir de la transparence, alors il te faut un alpha channel dans
ton image.
TYPE_INT_RGBA .. et utilise un logiciel d'imagerie pour editer l'alpha
channel dans ton image avant de la charger dans ton programme.
mBufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB);
Si tu veux avoir de la transparence, alors il te faut un alpha channel dans ton image. TYPE_INT_RGBA .. et utilise un logiciel d'imagerie pour editer l'alpha channel dans ton image avant de la charger dans ton programme.