Convertir 3 images en une seule.

cs_Gargantuass Messages postés 11 Date d'inscription mercredi 2 avril 2008 Statut Membre Dernière intervention 4 mai 2008 - 5 avril 2008 à 19:22
cs_coq Messages postés 6351 Date d'inscription samedi 1 juin 2002 Statut Membre Dernière intervention 2 août 2014 - 12 avril 2008 à 21:04
Bonjours à tous, 

      voila je commence tout juste à manipuler la language C# et dans le cadre d'un projet je cherche à réaliser une méthode qui prend en paramètre 3 images et qui retourne 1 seule image (bien sur cette image est composé des 3 premières).

J'attend de vos réponses avec impatience.

6 réponses

cs_coq Messages postés 6351 Date d'inscription samedi 1 juin 2002 Statut Membre Dernière intervention 2 août 2014 101
5 avril 2008 à 19:29
Salut,

Composée ?

/*
coq
MVP Visual C#
CoqBlog
*/
0
cs_Gargantuass Messages postés 11 Date d'inscription mercredi 2 avril 2008 Statut Membre Dernière intervention 4 mai 2008
5 avril 2008 à 19:54
Oui composé je veux pouvoir faire de la transparance à partir de 3 images en avoir une seule à la fin.
0
Lutinore Messages postés 3246 Date d'inscription lundi 25 avril 2005 Statut Membre Dernière intervention 27 octobre 2012 41
6 avril 2008 à 02:15
Salut, le mieux c'est d'utiliser des images qui contiennent déja un channel alpha ( PNG ) ça évite de manipuler les matrices, ce qui est compliqué et sûrement couteux en temps CPU.

Bitmap bmp0 = new Bitmap( 640, 480, PixelFormat.Format32bppArgb );
Bitmap bmp1 = Properties.Resources._01;
Bitmap bmp2 = Properties.Resources._02;
Bitmap bmp3 = Properties.Resources._03;


float[ ][ ] matrix =
{
    new float[ ] { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f },
    new float[ ] { 0.0f, 1.0f, 0.0f, 0.0f, 0.0f },
    new float[ ] { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f },
    new float[ ] { 0.0f, 0.0f, 0.0f, 0.5f, 0.0f },
    new float[ ] { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }
};


ImageAttributes imageAttributes = new ImageAttributes( );
imageAttributes.SetColorMatrix( new ColorMatrix( matrix ) );


using ( Graphics g = Graphics.FromImage( bmp0 ) )
{
    g.DrawImage( bmp1, 0, 0, bmp0.Width, bmp0.Height );
    g.CompositingMode = CompositingMode.SourceOver;
    g.CompositingQuality = CompositingQuality.HighQuality;
    g.DrawImage( bmp2, new Rectangle( 0, 0, bmp0.Width, bmp0.Height ),
        0, 0, bmp2.Width, bmp2.Height, GraphicsUnit.Pixel, imageAttributes );
    g.DrawImage( bmp3, new Rectangle( 0, 0, bmp0.Width, bmp0.Height ),
        0, 0, bmp3.Width, bmp3.Height, GraphicsUnit.Pixel, imageAttributes );
}


this.BackgroundImage = bmp0;
this.BackgroundImageLayout = ImageLayout.Center;
0
cs_Gargantuass Messages postés 11 Date d'inscription mercredi 2 avril 2008 Statut Membre Dernière intervention 4 mai 2008
6 avril 2008 à 20:07
Salut Lutinor j'ai un problème avec ta solution il manque un appel
de librairie pour Imageattribut laquel c'est ?

Merci a tous de bien vouloir vous pencher sur mon problème.
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Lutinore Messages postés 3246 Date d'inscription lundi 25 avril 2005 Statut Membre Dernière intervention 27 octobre 2012 41
7 avril 2008 à 10:34
Tu n'as pas la documentation du framework !? Télécharge la MSDN ou le SDK ou au moins la MDSN express.

Il faut ajouter la namespace System.Drawing.Imaging
0
Rejoignez-nous