Different people have tried this in different ways. For me, configuring ALSA to capture from the "Mix" device didn't work since I don't have a "Mix" listed when I try the amixer command. I could however write the ALSA output to a file by configuring the PCM chain.
Have the following code in your ~/.asoundrc file:
While not common, in rare cases you may have an image in its raw pixel format (say in rgb565). It can even be a portion of video. If you ever come accross converting such raw data to say a png or jpeg image, ffmpeg can be used easily. See the following command:
ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgb565 -s 1024x768 -i image.raw -f image2 -vcodec png image.png
1024x768 is the geometry. image.raw is the file containing the image in rgb565 format. image.png is the new file to be written.