| 3342 | } |
| 3343 | |
| 3344 | bool ccGLWindowInterface::renderToFile( QString filename, |
| 3345 | float zoomFactor/*=1.0*/, |
| 3346 | bool dontScaleFeatures/*=false*/, |
| 3347 | bool renderOverlayItems/*=false*/) |
| 3348 | { |
| 3349 | if (filename.isEmpty() || zoomFactor < 1.0e-2f) |
| 3350 | { |
| 3351 | return false; |
| 3352 | } |
| 3353 | |
| 3354 | QImage outputImage = renderToImage(zoomFactor, dontScaleFeatures, renderOverlayItems); |
| 3355 | |
| 3356 | if (outputImage.isNull()) |
| 3357 | { |
| 3358 | //an error occurred (message should have already been issued!) |
| 3359 | return false; |
| 3360 | } |
| 3361 | |
| 3362 | if (getDisplayParameters().drawRoundedPoints) |
| 3363 | { |
| 3364 | //convert the image to plain RGB to avoid issues with points transparency when saving to PNG |
| 3365 | outputImage = outputImage.convertToFormat(QImage::Format_RGB32); |
| 3366 | } |
| 3367 | |
| 3368 | bool success = outputImage.convertToFormat(QImage::Format_RGB32).save(filename); |
| 3369 | if (success) |
| 3370 | { |
| 3371 | ccLog::Print(QString("[Snapshot] File '%1' saved! (%2 x %3 pixels)").arg(filename).arg(outputImage.width()).arg(outputImage.height())); |
| 3372 | } |
| 3373 | else |
| 3374 | { |
| 3375 | ccLog::Warning(QString("[Snapshot] Failed to save file '%1'!").arg(filename)); |
| 3376 | } |
| 3377 | |
| 3378 | return success; |
| 3379 | } |
| 3380 | |
| 3381 | void ccGLWindowInterface::SetShaderPath(const QString& path) |
| 3382 | { |