2012-09-21 3 views
0

WPF에서 BitmapSource의 팔레트를 변경하는 방법이 있습니까? (런타임시) 시도한 모든 BitmapSource 계층에는 팔레트에 대한 읽기 전용 액세스 권한이 있습니다.BitmapSource 팔레트 변경

답변

0

나는 좋은 방법으로 그것을 할 수있는 방법을 발견하지 않은,하지만 당신은 항상 원래의 비트 맵을 다시 만들 수 있습니다 : 당신이있는 경우

을 : 다음

Private myBitmap As System.Windows.Media.Imaging.WriteableBitmap 
Private myCurrentPalette As List(Of Color) 

을 원할 때 팔레트 이렇게 변경 :

Dim iWidth As Integer = myBitmap.Width 
    Dim iHeight As Integer = myBitmap.Height 
    Dim iPixel(iWidth * iHeight - 1) As Byte 
    myBitmap.CopyPixels(iPixel, iWidth, 0) 
    myBitmap = New WriteableBitmap(iWidth, iHeight, 96, 96, PixelFormats.Indexed8, New BitmapPalette(myCurrentPalette)) 
    myBitmap.WritePixels(New Int32Rect(0, 0, iWidth, iHeight), iPixel, iWidth, 0) 

는 그런 다음 적용해야합니다

Image1.Source = myBitmap

+0

높이를 '-1'로 만들 때 배열을 만들 때 왜? 그렇게 픽셀 행을 잃지 않습니까? – Nyerguds