In WPF, BitmapSource has a
Palette[
^] property, however consider that not all image formats has palette. Only indexed (like tiff, gif and some kind of bitmap) formats has palette, for other formats you have to scan the image pixels and gather the color information from there...