@brief Read an entire image into contiguous memory performing conversions to @a format. Default implementation for derived classes. @sa readScanline() for support conversions.
| 308 | /// |
| 309 | /// @sa readScanline() for support conversions. |
| 310 | void |
| 311 | ImageInput::readImage(void* pBuffer, size_t bufferByteCount, |
| 312 | uint32_t subimage, uint32_t miplevel, |
| 313 | const FormatDescriptor& format) |
| 314 | { |
| 315 | const auto& targetFormat = format.isUnknown() ? spec().format() : format; |
| 316 | size_t outScanlineByteCount |
| 317 | = targetFormat.pixelByteCount() * spec().width(); |
| 318 | if (bufferByteCount < outScanlineByteCount * spec().height()) |
| 319 | throw buffer_too_small(); |
| 320 | |
| 321 | uint8_t* pDst = static_cast<uint8_t*>(pBuffer); |
| 322 | for (uint32_t y = 0; y < spec().height(); y++) { |
| 323 | readScanline(pDst, bufferByteCount, |
| 324 | y, 0, subimage, miplevel, targetFormat); |
| 325 | pDst += outScanlineByteCount; |
| 326 | bufferByteCount -= outScanlineByteCount; |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | void ImageInput::throwOnReadFailure() |
| 331 | { |
no test coverage detected