Picturebox, label transparent ???

Résolu
Rlooping Messages postés 13 Date d'inscription lundi 28 novembre 2005 Statut Membre Dernière intervention 2 février 2018 - 25 sept. 2006 à 15:15
P0lO Messages postés 65 Date d'inscription mercredi 18 avril 2007 Statut Membre Dernière intervention 12 juin 2008 - 8 août 2007 à 16:44
Comment afficher une image dans un picturebox avec transparence ??? Un label transparent sur une image ???

Merci

1 réponse

P0lO Messages postés 65 Date d'inscription mercredi 18 avril 2007 Statut Membre Dernière intervention 12 juin 2008 1
8 août 2007 à 16:44
Bonjour!
pour afficher une image avec transparence dans le compact framework, le seul moyen à prioris est de l'afficher en utilisant un composant System.Drawing.Graphic ensuite voila une petite fonction maison :P :

public static void DrawImageTransparent(System.Drawing.Graphics g, System.Drawing.Point point, System.Drawing.Bitmap symbol)
{
    System.Drawing.Rectangle R = new System.Drawing.Rectangle(point.X - symbol.Width / 2, point.Y - symbol.Height / 2, symbol.Width, symbol.Height);
    System.Drawing.Imaging.ImageAttributes attr = new System.Drawing.Imaging.ImageAttributes();
    attr.SetColorKey(symbol.GetPixel(0, 0), symbol.GetPixel(0, 0));
    g.DrawImage(symbol, R, 0, 0, symbol.Width, symbol.Height, System.Drawing.GraphicsUnit.Pixel, attr);   
}

g est la zone graphic sur laquelle ton image doit être déssinée, point contient les coordonnée du centre de l'image à déssiner, symbol est l'image à déssiner,...
"attr.SetColorKey(symbol.GetPixel(0, 0), symbol.GetPixel(0, 0));" c'est ici que tu va rendre la couleur de choix transparente à l'affichage, ici on prend arbitrairement comme couleur à rendre transparente la couleur du pixel de coordonnées x=0 et y=0.

voila en cas de problème hésite pas...

Cordialement.

CHERPITEL Paul (fan_ff60@hotmail.com)
3
Rejoignez-nous