title: how to convert 16-bit RGB Frame Buffer to a viewable format?
body: <p>I'm working with someone else's code on a device which can put an image to <code>/dev/fb/0</code> and show up on video out or send it over the network to a client application.</p>
  
  <p>I don't have access to the old source for the client app, but I know the following about the data:</p>
  
  <ul>
  <li>720x480</li>
  <li>16-bit </li>
  <li>RGB (I'm no sure if it's 5,5,5 or 5,6,5)</li>
  <li>RAW (no headers whatsoever)</li>
  <li><code>cat</code>-able to <code>/dev/fb/0</code></li>
  <li>675kb</li>
  </ul>
  
  <p>How can I give this a header or convert it to JPEG, BMP, or a RAW type that I could then view in a desktop application?</p>
  
  <p>Ultimately, I want it to be jpeg and viewable in a browser, but anything I can see with my eyes will work for now.</p>
  
  <h1>Success</h1>
  
  <p>(see the comments below)</p>
  
  <pre><code>ffmpeg \
    -vcodec rawvideo \
    -f rawvideo \
    -pix_fmt rgb565 \
    -s 720x480 \
    -i in-buffer.raw \
    \
    -f image2 \
    -vcodec mjpeg \
    out-buffer.jpg
  </code></pre>
  
  <ul>
  <li><a href="https://github.com/coolaj86/image-examples" rel="nofollow">github.com/coolaj86/image-examples</a></li>
  <li><a href="https://github.com/coolaj86/image-examples/blob/master/scripts/rgbtools-torgb" rel="nofollow">image-examples/scripts/rgbtools-torgb</a></li>
  <li><a href="https://github.com/coolaj86/image-examples/blob/master/scripts/rgbtools-fromrgb" rel="nofollow">image-examples/scripts/rgbtools-fromrgb</a></li>
  </ul>
  
  <h1>Failed Attempts</h1>
  
  <p>Shows the image three times widthwise with almost no color, and squashed vertically:</p>
  
  <pre><code>rawtoppm -rgb -interpixel 720 480 fb.raw &gt; fb.ppm
  </code></pre>
  
  <p>Shows the image, but with streaks and squashed vertically and bad color:</p>
  
  <pre><code>rawtoppm -rgb -interrow 720 480 fb.raw &gt; fb.ppm
  </code></pre>
  
  <p>Similar to the above</p>
  
  <pre><code>convert -depth 16 -size 720x480 frame_buffer.rgb fb.jpeg
  </code></pre>