Bonjour,

j'essaye d'ouvrir une image en .bmp.
J'obtiens bien des données. cependant la taille ne correspond pas : j'ai des doubles par exemple pour la hauteurcomme 463,765... alors que la hauteur est 560.

voici le 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
Uri uri = new Uri(name);
            BmpBitmapDecoder decoder = new BmpBitmapDecoder(uri, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
            BitmapSource bmpI = decoder.Frames[0]; 
            WriteableBitmap bmp = new WriteableBitmap(bmpI);
                if (bmpI.Format == PixelFormats.Indexed8)
                {
                    pixels = new int[(int)(4 * bmpI.Height * bmpI.Width)];
                    bmpI.CopyPixels(pixels, (int)(4 * bmpI.Width), 0);
                }
                if (bmpI.Format == PixelFormats.Bgr24)
                {
                    //MessageBox.Show(bmpI.Height.ToString()+" "+bmpI.Width.ToString());
                    pixels = new int[(int)(4 * bmpI.Height * bmpI.Width)];
                    bmpI.CopyPixels(pixels, (int)(4 * bmpI.Width), 0);
                }