MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / Save

Method Save

src/Frame.cpp:515–540  ·  view source on GitHub ↗

Save the frame image to the specified path. The image format is determined from the extension (i.e. image.PNG, image.JPEG)

Source from the content-addressed store, hash-verified

513
514// Save the frame image to the specified path. The image format is determined from the extension (i.e. image.PNG, image.JPEG)
515void Frame::Save(std::string path, float scale, std::string format, int quality)
516{
517 // Get preview image
518 std::shared_ptr<QImage> previewImage = GetImage();
519
520 // Update the image to reflect the correct pixel aspect ration (i.e. to fix non-square pixels)
521 if (pixel_ratio.num != 1 || pixel_ratio.den != 1)
522 {
523 // Resize to fix DAR
524 previewImage = std::make_shared<QImage>(previewImage->scaled(
525 previewImage->size().width(), previewImage->size().height() * pixel_ratio.Reciprocal().ToDouble(),
526 Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
527 }
528
529 // scale image if needed
530 if (fabs(scale) > 1.001 || fabs(scale) < 0.999)
531 {
532 // Resize image
533 previewImage = std::make_shared<QImage>(previewImage->scaled(
534 previewImage->size().width() * scale, previewImage->size().height() * scale,
535 Qt::KeepAspectRatio, Qt::SmoothTransformation));
536 }
537
538 // Save image
539 previewImage->save(QString::fromStdString(path), format.c_str(), quality);
540}
541
542// Thumbnail the frame image to the specified path. The image format is determined from the extension (i.e. image.PNG, image.JPEG)
543void Frame::Thumbnail(std::string path, int new_width, int new_height, std::string mask_path, std::string overlay_path,

Callers 6

WriteFrameMethod · 0.45
AddMethod · 0.45
Profiles.cppFile · 0.45
Clip.cppFile · 0.45
Caption.cppFile · 0.45

Calls 2

ToDoubleMethod · 0.80
ReciprocalMethod · 0.80

Tested by

no test coverage detected