Cet article a fait l'objet d'une traduction automatique. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte. Informations supplémentaires.
Traduction
Source
Ce sujet n'a pas encore été évalué - Évaluez ce sujet

BitmapEncoder.Palette, propriété

Obtient ou définit une valeur qui représente le BitmapPalette d'une bitmap encodée.

Espace de noms :  System.Windows.Media.Imaging
Assembly :  PresentationCore (dans PresentationCore.dll)
public virtual BitmapPalette Palette { get; set; }

Valeur de propriété

Type : System.Windows.Media.Imaging.BitmapPalette
Instance de BitmapPalette.
ExceptionCondition
ArgumentNullException

La valeur BitmapPalette passée à l'encodeur est null.

Seules les images TIFF (Tagged Image File Format) et GIF (Graphics Interchange Format) (et quelques images BMP (Bitmap) plus anciennes, non standard) prennent en charge des palettes.

L'exemple suivant montre comment appliquer une palette personnalisée à une image TIFF (Tagged Image File Format) et comment l'encoder par la suite.


            int width = 128;
            int height = width;
            int stride = width/8;
            byte[] pixels = new byte[height*stride];

            // Try creating a new image with a custom palette.
            List<System.Windows.Media.Color> colors = new List<System.Windows.Media.Color>();
            colors.Add(System.Windows.Media.Colors.Red);
            colors.Add(System.Windows.Media.Colors.Blue);
            colors.Add(System.Windows.Media.Colors.Green);
            BitmapPalette myPalette = new BitmapPalette(colors);

            // Creates a new empty image with the pre-defined palette

            BitmapSource image = BitmapSource.Create(
                width,
                height,
                96,
                96,
                PixelFormats.Indexed1,
                myPalette, 
                pixels, 
                stride);

            FileStream stream = new FileStream("empty.tif", FileMode.Create);
            TiffBitmapEncoder encoder = new TiffBitmapEncoder();
            TextBlock myTextBlock = new TextBlock();
            myTextBlock.Text = "Codec Author is: " + encoder.CodecInfo.Author.ToString();
            encoder.Frames.Add(BitmapFrame.Create(image));
            MessageBox.Show(myPalette.Colors.Count.ToString());
            encoder.Save(stream);



.NET Framework

Pris en charge dans : 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Pris en charge dans : 4, 3.5 SP1

Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (rôle principal du serveur non pris en charge), Windows Server 2008 R2 (rôle principal du serveur pris en charge avec SP1 ou version ultérieure ; Itanium non pris en charge)

Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.
Cela vous a-t-il été utile ?
(1500 caractères restants)

Ajouts de la communauté

AJOUTER
© 2013 Microsoft. Tous droits réservés.