Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
864 views
in Technique[技术] by (71.8m points)

uwp - How to retain Windows.UI.Xaml.Controls.Image content color irrespective of layout background color?

Windows.UI.Xaml.Controls.Image content color changed when background-color changes in Layout. How to retain Windows.UI.Xaml.Controls.Image content color?

Issue Facing

Image color combined with the layout background-color as below screenshots

Background Color - Black Background Color - Black

Background Color - White Background Color - White

Background Color - Green Background Color - Green

The content color is dynamically changing with respect to the layout background-color

Expected Solution

The content color should be the same irrespective of the layout background-color

Sample link : https://drive.google.com/file/d/1KXp3yCYSBmgbKsXVNjB6T0LPsl6Pply8/view?usp=sharing

Replication procedure

  1. Run the sample

  2. Click Button(Name: Color)(When background changes. Image content color will also change)

question from:https://stackoverflow.com/questions/65840123/how-to-retain-windows-ui-xaml-controls-image-content-color-irrespective-of-layou

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

WriteableBitmap Class provides a BitmapSource that can be written to and updated, and the whole picture is one, which causes the color of the image to be affected by the Canvas background. When the background of Canvas becomes green, red and green are superimposed, so the red pattern becomes yellow.

To do this, when you change the background of Canvas, you could traverse the pixels of the entire picture, and if you find a pixel block that is not red, then change it. Please refer to the second reply of this question.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...