#include <algorithm>
#include "tools.hh"

using namespace mimas;
using namespace std;

image< rgba< unsigned char > > qImageToMimasImage( const QImage &qImg )
{
  QImage temp( qImg.convertToFormat( QImage::Format_RGB32 ) );
  image< rgba< unsigned char > > retVal;
  retVal.init( temp.width(), temp.height() );
  rgba< unsigned char > *p = retVal.rawData();
  for( int y=0; y<temp.height(); y++ ) {
    copy( (const rgba< unsigned char > *)temp.scanLine( y ),
          (const rgba< unsigned char > *)temp.scanLine( y ) +
          temp.width(), p );
    p += temp.width();
  };
  return retVal;
}