MCPcopy Create free account
hub / github.com/IENT/YUView / loadCurrentImageFromFile

Method loadCurrentImageFromFile

YUViewLib/src/video/FrameHandler.cpp:163–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161}
162
163bool FrameHandler::loadCurrentImageFromFile(const QString &filePath)
164{
165 auto extension = QFileInfo(filePath).suffix().toLower();
166 if (extension == "tga" || extension == "icb" || extension == "vda" || extension == "vst")
167 {
168 auto image = dec::Targa::loadTgaFromFile(filePath.toStdString());
169 if (!image)
170 return false;
171
172 // Convert byte array to QImage
173 this->setFrameSize(Size(image->size.width, image->size.height));
174 auto qFrameSize = QSize(image->size.width, image->size.height);
175 this->currentImage = QImage(qFrameSize, QImage::Format_ARGB32);
176 for (unsigned y = 0; y < image->size.height; y++)
177 {
178 auto bits = this->currentImage.scanLine(y);
179 for (unsigned x = 0; x < image->size.width; x++)
180 {
181 auto idx = y * image->size.width * 4 + x * 4;
182 // Src is RGBA and output it BGRA
183 bits[2] = image->data.at(idx);
184 bits[1] = image->data.at(idx + 1);
185 bits[0] = image->data.at(idx + 2);
186 bits[3] = image->data.at(idx + 3);
187 bits += 4;
188 }
189 }
190 }
191 else
192 {
193 // Load the image and return if loading was successful
194 this->currentImage = QImage(filePath);
195 auto qFrameSize = currentImage.size();
196 this->setFrameSize(Size(qFrameSize.width(), qFrameSize.height()));
197 }
198
199 return (!this->currentImage.isNull());
200}
201
202void FrameHandler::savePlaylist(YUViewDomElement &element) const
203{

Callers 1

loadFrameMethod · 0.80

Calls 4

setFrameSizeMethod · 0.95
SizeClass · 0.85
atMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected