44 lines
690 B
C++
44 lines
690 B
C++
#include "utils.h"
|
|
#include <QFile>
|
|
#include <QTextStream>
|
|
#include <QImage>
|
|
|
|
std::string Utils::fileToString(const std::string &filename)
|
|
{
|
|
QFile f(QString(filename.c_str()));
|
|
if(!f.open(QFile::ReadOnly | QFile::Text))
|
|
return NULL;
|
|
QTextStream in(&f);
|
|
return in.readAll().toStdString();
|
|
}
|
|
|
|
Utils::Image::Image(std::string filename)
|
|
{
|
|
img = new QImage(QString(filename.c_str()));
|
|
}
|
|
|
|
Utils::Image::~Image()
|
|
{
|
|
delete(img);
|
|
}
|
|
|
|
int Utils::Image::depth()
|
|
{
|
|
return img->depth();
|
|
}
|
|
|
|
int Utils::Image::width()
|
|
{
|
|
return img->width();
|
|
}
|
|
|
|
int Utils::Image::height()
|
|
{
|
|
return img->height();
|
|
}
|
|
|
|
void* Utils::Image::pixels()
|
|
{
|
|
return (void*)img->bits();
|
|
}
|