Foreground/background colors are defined in the raws, not as part of the png. The color tags and their values are on the wiki
here. When displaying a tile, the game puts background color behind the tile, and foreground in front of it. Background color thus can only be seen in transparent or partially transparent areas. Fully transparent areas will show full background color, and partially transparent areas will show the background color modified/darkened by whatever partially transparent part of the picture is on top of it. The more transparent an area, the more of the background color shows through.
As for foreground color, it's put down on top of the tile on opaque or partially opaque areas. It's tricky, though: the game looks at where it's putting down foreground color
and mixes that color with whatever color is already there in the tile. So on white areas, you just get the regular foreground color. Black parts of the tile stay black, and gray areas produce darker parts of the foreground color depending on how dark the grey was. If the tile graphic has other colors on it, like the brown tree trunks, those are also averaged with the foreground color. It's generally not too noticeable in regular-size tilesets, I think (rather shakier on this, since I've avoided it in my own personal tileset, but I'm pretty sure that's how it works). Foreground color shows up less on partially transparent areas, and doesn't show up at all on completely transparent areas. So in practice, on areas of partial opacity/transparency, you'll have a mix of foreground color, background color, and whatever color/shade the picture is.
So basically, doing it Phoebus' way will make the trunks look a bit off as the game tries to mix foreground color with the brown of the trunk, BUT doing it my way requires editing the tree's raw file, which is generally to be avoided if you're trying to make a user-friendly set. I'll upload a psd later if you want to look, but you shouldn't need it. Photoshop layers aren't really involved; the transparency you see in the png files is doing all the work.