[gdal-dev] Best way to read jpeg interleaved

Javier Jimenez Shaw j1 at jimenezshaw.com
Thu Dec 17 10:28:29 PST 2020


Hi

I want to read quickly a jpeg file, and store it in memory interleaved
(RGBRGBRGB).
Is this the fastest way to read it?
(note: dest is already allocated to the proper size)

void loadImageRGBUint8(const std::string& path, void* dest) { auto dataSet
= static_cast<GDALDataset*>(GDALOpen(path.c_str(), GA_ReadOnly))); // check
dataSet ...
const auto width = dataSet->GetRasterXSize(); const auto height =
dataSet->GetRasterYSize(); const auto rasterReturn =
dataSet->RasterIO(GF_Read, 0, // top 0, // left width, height, dest, width,
height, GDT_Byte, 3, // bands nullptr, 3, // nPixelSpace 3 * width, //
nLineSpace 1, // nBandSpace nullptr); // ...check rasterReturn and destroy
dataSet ... }

Regarding the parameter "nLineSpace", documentation says
nLineSpace The byte offset from the start of one scanline in pData to the
start of the next. If defaulted (0) the size of the datatype eBufType *
nBufXSize is used.
In the code above, if I set nLineSpace to 0, it works fine. However, if I
write what documentation says ( 1 * width ), it does not work. Is this a
bug in the documentation, or am I understanding it wrongly?

Thanks
.___ ._ ..._ .. . ._.  .___ .. __ . _. . __..  ... .... ._ .__
Entre dos pensamientos racionales
hay infinitos pensamientos irracionales.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20201217/bfa7ccfd/attachment.html>


More information about the gdal-dev mailing list