I have a black on transparent icon in a png file. I want to use this icon at different locations in a LaTeX document in different colors. As a bonus it would be good if I can give the upper half of the icon a different color than the lower half because it sometimes appears on the border of different backgrounds.
This answer shows how to colorize a grayscale png file and it's easy to give the upper half a different color than the lower half. Unfortunately, it requires the logo to be on a white background:
\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\fill[yellow!50!white] (0,1) rectangle (2,2);
\fill[gray!50!black] (0,0) rectangle (2,1);
\begin{scope}[blend group=screen]
\node[inner sep=0,line width=0] (logo) at (1,1) [anchor=center] {\includegraphics{icon-bw}};
\fill[blue] (logo.west) rectangle (logo.north east);
\fill[green] (logo.south west) rectangle (logo.east);
\end{scope}
\end{tikzpicture}
\end{document}
An example icon with white background added:

If I use a black to transparent png instead the entire node is painted blue and green.
An example icon with transparent background:

This answer shows how to use a png file as transparency mask. But how do I move the icon so that it's centered at (1,1)?
\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{fadings}
\begin{tikzfadingfrompicture}[name=icon]
\begin{scope}[transparency group]
\node (icon) [fill, draw, white] {\includegraphics[height=1cm]{icon}};
\begin{scope}[blend mode=difference]
\fill[white] (icon.south west) rectangle (icon.north east);
\end{scope}
\end{scope}
\end{tikzfadingfrompicture}
\begin{document}
\begin{tikzpicture}
\fill[yellow!50!white] (0,1) rectangle (2,2);
\fill[gray!50!black] (0,0) rectangle (2,1);
% How I intend to use it
\begin{scope}[scope fading=icon, fit fading=false]
\fill[blue] (0.5,1) rectangle (1.5,1.5);
\fill[green] (0.5,0.5) rectangle (1.5,1);
\end{scope}
% Approach of the original answer. The icon is not positioned correctly.
% The specified coordinate does not seem to make any difference.
\path[scope fading=icon,fit fading=false] (1,1);
\node[fill=yellow,minimum width=1cm,minimum height=1cm] {};
\end{tikzpicture}
\end{document}
In my real use case the icon consists of black and transparency, only. So it would be acceptable if an answer does not work with intermediate gray tones.

