Bonjour à tous,

Cela fait quelques jours que je bloque sur un problème :
J'ai une trackbar qui me permet de changer la luminosité d'une image mais celle-ci ne fait qu'augmenter la luminosité, sans la baisser !

Voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 
public static Bitmap AdjustBrightness(Bitmap Image, int Value)
        {
            Bitmap TempBitmap = Image;
 
            Bitmap NewBitmap = new Bitmap(TempBitmap.Width, TempBitmap.Height);
 
            Graphics NewGraphics = Graphics.FromImage(NewBitmap);
 
            float FinalValue = (float)Value / 255.0f;
            FinalValue *= 4;
 
            float[][] FloatColorMatrix ={
 
                     new float[] {1, 0, 0, 0, 0},
 
                     new float[] {0, 1, 0, 0, 0},
 
                     new float[] {0, 0, 1, 0, 0},
 
                     new float[] {0, 0, 0, 1, 0},
 
                     new float[] {FinalValue, FinalValue, FinalValue, 1, 1}
                 };
 
            ColorMatrix NewColorMatrix = new ColorMatrix(FloatColorMatrix);
 
            ImageAttributes Attributes = new ImageAttributes();
 
            Attributes.SetColorMatrix(NewColorMatrix);
 
            NewGraphics.DrawImage(TempBitmap, new Rectangle(0, 0, TempBitmap.Width, TempBitmap.Height), 0, 0, TempBitmap.Width, TempBitmap.Height, GraphicsUnit.Pixel, Attributes);
 
            Attributes.Dispose();
 
            NewGraphics.Dispose();
 
            return NewBitmap;
        }
Qqn a une piste ou pourrait m'éclairer svp ?
Merci d'avance