MCPcopy Create free account
hub / github.com/KhronosGroup/KTX-Software / readImage

Method readImage

tools/imageio/imageinput.cc:310–328  ·  view source on GitHub ↗

@brief Read an entire image into contiguous memory performing conversions to @a format. Default implementation for derived classes. @sa readScanline() for support conversions.

Source from the content-addressed store, hash-verified

308///
309/// @sa readScanline() for support conversions.
310void
311ImageInput::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
330void ImageInput::throwOnReadFailure()
331{

Callers 2

loadInputImageMethod · 0.45
createImageMethod · 0.45

Calls 6

buffer_too_smallClass · 0.85
isUnknownMethod · 0.80
pixelByteCountMethod · 0.80
widthMethod · 0.80
heightMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected