use thumbnails for now...
This commit is contained in:
		@ -2,6 +2,10 @@
 | 
			
		||||
 | 
			
		||||
#include "sai.hpp"
 | 
			
		||||
 | 
			
		||||
#include <QFile>
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#include <QImage>
 | 
			
		||||
 | 
			
		||||
SAIHandler::SAIHandler()
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
@ -18,10 +22,33 @@ bool SAIHandler::canRead() const
 | 
			
		||||
 | 
			
		||||
bool SAIHandler::read(QImage *image)
 | 
			
		||||
{
 | 
			
		||||
    Q_UNUSED(image)
 | 
			
		||||
    QFile * file = qobject_cast<QFile*>(device());
 | 
			
		||||
    if (!file) {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    sai::Document saiDoc(file->fileName().toUtf8().data());
 | 
			
		||||
    if (!saiDoc.IsOpen()) {
 | 
			
		||||
        qDebug() << "isOpen false";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    std::uint32_t width, height;
 | 
			
		||||
    std::unique_ptr<std::uint8_t[]> PixelData;
 | 
			
		||||
    std::tie(PixelData, width, height) = saiDoc.GetThumbnail();
 | 
			
		||||
//    std::uint32_t aw, ah;
 | 
			
		||||
//    std::tie(aw, ah) = saiDoc.GetCanvasSize();
 | 
			
		||||
//    qDebug() << width << height << aw << ah;
 | 
			
		||||
    if( PixelData == nullptr || !width || !height ) {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const unsigned char * bytes = PixelData.get();
 | 
			
		||||
    QImage img(bytes, static_cast<int>(width), static_cast<int>(height), QImage::Format_RGB32);
 | 
			
		||||
    *image = img;
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool SAIHandler::write(const QImage &image)
 | 
			
		||||
{
 | 
			
		||||
    Q_UNUSED(image)
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user