BitmapPalette 클래스

정의

지원되는 이미지 형식에 대해 사용 가능한 색상표를 정의합니다.

public ref class BitmapPalette sealed : System::Windows::Threading::DispatcherObject
public sealed class BitmapPalette : System.Windows.Threading.DispatcherObject
type BitmapPalette = class
    inherit DispatcherObject
Public NotInheritable Class BitmapPalette
Inherits DispatcherObject
상속
BitmapPalette

예제

다음 예제에서는 사용자 지정을 정의하고 새 BitmapSource사용자 지정 BitmapPalette 에 적용하는 방법을 보여 줍니다.

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);
Dim width As Integer = 128
Dim height As Integer = width
Dim stride As Integer = CType(width / 8, Integer)
Dim pixels(height * stride) As Byte

' Try creating a new image with a custom palette.
Dim colors As New List(Of 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)
Dim myPalette As New BitmapPalette(colors)

' Creates a new empty image with the pre-defined palette
Dim image As BitmapSource = System.Windows.Media.Imaging.BitmapSource.Create(width, height, 96, 96, PixelFormats.Indexed1, myPalette, pixels, stride)
Dim stream As New FileStream("empty.tif", FileMode.Create)
Dim encoder As New TiffBitmapEncoder()
Dim myTextBlock As 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)

다음 예제에서는 이미지에서 검색하는 BitmapPalette 방법을 보여 줍니다.


// Get the palette from an image
BitmapImage image2 = new BitmapImage();
image2.BeginInit();
image2.UriSource = new Uri("tulipfarm.tif", UriKind.RelativeOrAbsolute);
image2.EndInit();
BitmapPalette myPalette3 = new BitmapPalette(image2, 256);

//Draw the third Image
Image myImage2 = new Image();
myImage2.Source = image2;
myImage2.Stretch = Stretch.None;
myImage2.Margin = new Thickness(20);
' Get the palette from an image
Dim image2 As New BitmapImage()
image2.BeginInit()
image2.UriSource = New Uri("tulipfarm.tif", UriKind.RelativeOrAbsolute)
image2.EndInit()
Dim myPalette3 As New BitmapPalette(image2, 256)

'Draw the third Image
Dim myImage2 As New Image()
myImage2.Source = image2
myImage2.Stretch = Stretch.None
myImage2.Margin = New Thickness(20)

설명

태그가 지정된 TIFF(이미지 파일 형식) 및 GIF(그래픽 교환 형식) 이미지 형식만 이미지 팔레트를 지원합니다. 그러나 다른 이미지 형식을 사용하여 을 정의 BitmapPalette할 수 있습니다. 지원되지 않는 비트맵 형식에 대한 정의를 BitmapPalette 시도해도 예외가 발생하지 않습니다. 지정된 BitmapPalette 항목은 무시됩니다.

WPF(Windows Presentation Foundation)는 사용자 지정 색상표와 클래스에서 정의한 BitmapPalettes 미리 정의된 색상표를 모두 지원합니다.

생성자

BitmapPalette(BitmapSource, Int32)

지정된 BitmapSource를 기반으로 한 BitmapPalette 클래스의 새 인스턴스를 초기화합니다. 새 BitmapPalette가 지정된 최대 색 수로 제한됩니다.

BitmapPalette(IList<Color>)

지정된 색을 사용하여 BitmapPalette 클래스의 새 인스턴스를 초기화합니다.

속성

Colors

색상표에 정의된 색을 가져옵니다.

Dispatcher

Dispatcher와 연결된 DispatcherObject를 가져옵니다.

(다음에서 상속됨 DispatcherObject)

메서드

CheckAccess()

호출 스레드가 이 DispatcherObject에 액세스할 수 있는지 여부를 확인합니다.

(다음에서 상속됨 DispatcherObject)
Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)
VerifyAccess()

호출 스레드에서 이 DispatcherObject에 액세스할 수 있는지 확인합니다.

(다음에서 상속됨 DispatcherObject)

적용 대상

추가 정보