Exracting pictures

This example shows how to extract all pictures from an Excel workbook.
#include "libxl.h"
#include <fstream>
#include <sstream>
#include <iostream>

using namespace libxl;

int main() 
{         
    Book* book = xlCreateXMLBook();

    bool b = book->load(L"in.xlsx");

    for(int i = 0; i < book->pictureSize(); ++i)
    {
        const char* data;
        unsignedsize;
        std::wstring ext;

        PictureType pt = book->getPicture(i, &data, &size);

        switch(pt)
        {
            case PICTURETYPE_PNG:  ext = L"png"; break;
            case PICTURETYPE_JPEG: ext = L"jpg"; break;
            case PICTURETYPE_GIF:  ext = L"gif"; break;
            case PICTURETYPE_WMF:  ext = L"wmf"; break;
            case PICTURETYPE_EMF:  ext = L"wmf"; break;
            case PICTURETYPE_TIFF: ext = L"tif"; break;            
        }

        std::wstringstream ss;
        ss << L"pic" << i << L"." << ext;
        std::wcout << L"writing " << ss.str().c_str() << std::endl;

        std::fstream stream(ss.str().c_str(), std::ios_base::out | std::ios_base::binary);
        stream.write(data, size);
    }
 
    book->release();
          
    return 0;
}