mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-15 00:54:38 +00:00
load and save image functions
This commit is contained in:
parent
a133962d8b
commit
eb257d8cb6
@ -185,7 +185,10 @@ void reloadMesh(
|
||||
loadMesh(filename, ioPlugin, prePar, meshList, masks, cb);
|
||||
}
|
||||
|
||||
void loadRaster(const QString& filename, RasterModel& rm, GLLogStream* log, vcg::CallBackPos* cb)
|
||||
QImage loadImage(
|
||||
const QString& filename,
|
||||
GLLogStream* log,
|
||||
vcg::CallBackPos* cb)
|
||||
{
|
||||
QFileInfo fi(filename);
|
||||
QString extension = fi.suffix();
|
||||
@ -194,15 +197,40 @@ void loadRaster(const QString& filename, RasterModel& rm, GLLogStream* log, vcg:
|
||||
|
||||
if (ioPlugin == nullptr)
|
||||
throw MLException(
|
||||
"Raster " + filename + " cannot be opened. Your MeshLab version "
|
||||
"Image " + filename + " cannot be opened. Your MeshLab version "
|
||||
"has not plugin to read " + extension + " file format.");
|
||||
|
||||
ioPlugin->setLog(log);
|
||||
QImage loadedImage = ioPlugin->openImage(extension, filename, cb);
|
||||
return ioPlugin->openImage(extension, filename, cb);
|
||||
}
|
||||
|
||||
void saveImage(
|
||||
const QString& filename,
|
||||
const QImage& image,
|
||||
GLLogStream* log,
|
||||
vcg::CallBackPos* cb)
|
||||
{
|
||||
QFileInfo fi(filename);
|
||||
QString extension = fi.suffix();
|
||||
PluginManager& pm = meshlab::pluginManagerInstance();
|
||||
IOPlugin *ioPlugin = pm.outputImagePlugin(extension);
|
||||
|
||||
if (ioPlugin == nullptr)
|
||||
throw MLException(
|
||||
"Image " + filename + " cannot be saved. Your MeshLab version "
|
||||
"has not plugin to save " + extension + " file format.");
|
||||
|
||||
ioPlugin->setLog(log);
|
||||
ioPlugin->saveImage(extension, filename, image, cb);
|
||||
}
|
||||
|
||||
void loadRaster(const QString& filename, RasterModel& rm, GLLogStream* log, vcg::CallBackPos* cb)
|
||||
{
|
||||
QImage loadedImage = loadImage(filename, log, cb);
|
||||
rm.setLabel(filename);
|
||||
rm.addPlane(new RasterPlane(loadedImage, filename, RasterPlane::RGBA));
|
||||
|
||||
// Read the JPEG file into a buffer
|
||||
// Read the file into a buffer
|
||||
FILE *fp = fopen(qUtf8Printable(filename), "rb");
|
||||
if (!fp) {
|
||||
QString errorMsgFormat = "Exif Parsing: Unable to open file:\n\"%1\"\n\nError details: file %1 is not readable.";
|
||||
@ -225,7 +253,7 @@ void loadRaster(const QString& filename, RasterModel& rm, GLLogStream* log, vcg:
|
||||
int code = ImageInfo.parseFrom(buf, fsize);
|
||||
delete[] buf;
|
||||
if (!code) {
|
||||
ioPlugin->log(GLLogStream::FILTER, "Warning: unable to parse exif for file %s", qPrintable(filename));
|
||||
log->log(GLLogStream::FILTER, "Warning: unable to parse exif for file " + filename);
|
||||
}
|
||||
|
||||
if (code && ImageInfo.FocalLengthIn35mm==0.0f)
|
||||
|
||||
@ -53,6 +53,17 @@ void reloadMesh(
|
||||
GLLogStream* log = nullptr,
|
||||
vcg::CallBackPos* cb = nullptr);
|
||||
|
||||
QImage loadImage(
|
||||
const QString& filename,
|
||||
GLLogStream* log = nullptr,
|
||||
vcg::CallBackPos *cb = nullptr);
|
||||
|
||||
void saveImage(
|
||||
const QString& filename,
|
||||
const QImage& image,
|
||||
GLLogStream* log = nullptr,
|
||||
vcg::CallBackPos* cb = nullptr);
|
||||
|
||||
void loadRaster(
|
||||
const QString& filename,
|
||||
RasterModel& rm,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user