是否需要在一個ImageList切換黑色像素,以黃色改變位圖的幫助,它們被用作用於UICommandBar圖像(屏幕截圖和下面嘗試)Windows.Forms的 - 更改的ImageList位圖像素高對比度
該代碼獲得執行,GetPixel條件,然後SetPixel,但圖像不會更改。可能與ImageListStreamer相關,或者不適合交換這些像素。
rtfeditor.cs
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1 = ColorSpace.ProcessHighContrast(this.imageList1);
的Utils \ ColorSpace.cs
public static System.Windows.Forms.ImageList ProcessHighContrast(System.Windows.Forms.ImageList imageList)
{
if (System.Windows.Forms.SystemInformation.HighContrast)
{
foreach (System.Drawing.Bitmap imageListImage in imageList.Images)
{
for (int i = 0; i < imageListImage.Width; i++)
{
for (int j = 0; j < imageListImage.Height; j++)
{
Color color = imageListImage.GetPixel(i, j);
if (System.Drawing.Color.FromArgb(255, 0, 0, 0).Equals(color))
imageListImage.SetPixel(i, j, System.Drawing.SystemColors.WindowText);
}
}
}
}
return imageList;
}
ImageList.Images返回*副本*每個圖像的。因此,更改副本不會修改ImageList內容。改爲創建一個新的ImageList。不要認爲Darth Vader配色方案傾向於只被程序員所欣賞,常規用戶期望高對比度版本具有白色背景。這將會減少很多痛苦。 –
謝謝你的回答。我改變了ProcessHighContrast方法來創建一個新的ImageList,並在處理後向它添加位圖。不幸的是它沒有奏效。 – siliond