I currently have the Samsung WB35f camera and it takes really great pictures and I recently changed the settings so the image quality was at super fine and they turned out better. My plan is too upgrade to Panasonic dmc-lz40 camera. The dmc-lz40 has a 20mp sensor while the wb35f has a 16mp sensor. I'm not an expert on cameras, but I do know a 20mp sensor while give you 4 more million pixels per shot than the wb35f 16mp camera, but does this mean the Panasonic dmc-lz40 takes better pictures or is their more factors that go into a camera to make the image quality greater.
More megapixels does not necessarily mean a better resulting image. As you alluded to, many more factors go into image quality beyond strictly megapixels. Megapixels or resolution is typically 10-15 spots down in the list of importance when I compare cameras.
The main differences between the two cameras that you noted are size, and optical zoom abilities. Beyond that, not much is different and they are likely on very similar when it comes to image quality (although admittedly I do not have first hand experience with either).
More information that you should read: