Display the frame image to the screen (primarily used for debugging reasons)
| 118 | |
| 119 | // Display the frame image to the screen (primarily used for debugging reasons) |
| 120 | void Frame::Display() |
| 121 | { |
| 122 | if (!QApplication::instance()) { |
| 123 | // Only create the QApplication once |
| 124 | static int argc = 1; |
| 125 | static char* argv[1] = {NULL}; |
| 126 | previewApp = std::make_shared<QApplication>(argc, argv); |
| 127 | } |
| 128 | |
| 129 | // Get preview image |
| 130 | std::shared_ptr<QImage> previewImage = GetImage(); |
| 131 | |
| 132 | // Update the image to reflect the correct pixel aspect ration (i.e. to fix non-square pixels) |
| 133 | if (pixel_ratio.num != 1 || pixel_ratio.den != 1) |
| 134 | { |
| 135 | // Resize to fix DAR |
| 136 | previewImage = std::make_shared<QImage>(previewImage->scaled( |
| 137 | previewImage->size().width(), previewImage->size().height() * pixel_ratio.Reciprocal().ToDouble(), |
| 138 | Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); |
| 139 | } |
| 140 | |
| 141 | // Create window |
| 142 | QWidget previewWindow; |
| 143 | previewWindow.setStyleSheet("background-color: #000000;"); |
| 144 | QHBoxLayout layout; |
| 145 | |
| 146 | // Create label with current frame's image |
| 147 | QLabel previewLabel; |
| 148 | previewLabel.setPixmap(QPixmap::fromImage(*previewImage)); |
| 149 | previewLabel.setMask(QPixmap::fromImage(*previewImage).mask()); |
| 150 | layout.addWidget(&previewLabel); |
| 151 | |
| 152 | // Show the window |
| 153 | previewWindow.setLayout(&layout); |
| 154 | previewWindow.show(); |
| 155 | previewApp->exec(); |
| 156 | } |
| 157 | |
| 158 | // Get an audio waveform image |
| 159 | std::shared_ptr<QImage> Frame::GetWaveform(int width, int height, int Red, int Green, int Blue, int Alpha) |
no test coverage detected