[gdal-dev] GDALDataset::RasterIO error when using negative nLineSpace

Omar Álvarez omar.alvarez at cinfo.es
Tue Oct 8 01:44:48 PDT 2019


Hi,

I'm trying to read an RGB image using GDAL. I have got it working, but my
image is upside down. This is the code I am using for that:

CPLErr err = geotiffDataset->RasterIO(
            GF_Write,
            0, 0,
            _image->s(), _image->t(),
            (void *)(_image->data()),
            _image->s(), _image->t(),
            cvtGLtoGDALType(_image),
            3, NULL,
            _image->getPixelSizeInBits() / CHAR_BIT ,
_image->getRowStepInBytes(), _image->getPixelSizeInBits() / 3 / CHAR_BIT
        );

But, if I try to use negative nLineSpace to flip it vertically:

 CPLErr err = geotiffDataset->RasterIO(
            GF_Write,
            0, 0,
            _image->s(), _image->t(),
            (void *)((char *)_image->data() + _image->getImageSizeInBytes()
- _image->getRowStepInBytes()),
            _image->s(), _image->t(),
            cvtGLtoGDALType(_image),
            3, NULL,
            _image->getPixelSizeInBits() / CHAR_BIT ,
-_image->getRowStepInBytes(), _image->getPixelSizeInBits() / 3 / CHAR_BIT
        );

I get a segfault.

Image is 1024x1024x3 and GDT_Float32. Anyone has any idea if I made a
mistake? Am I going about this wrong?

Thanks to everybody in advance.

Cheers,

Omar.

-- 
[image: logo cinfo]
<https://cinfo.es/?utm_source=mailing&utm_medium=logo&utm_campaign=trafico-generico&utm_content=index>
Luis Omar Álvarez MuresAI Software Development Coordinator

omar.alvarez at cinfo.es | +34 881 015 512
Edificio CITIC 2 - Antonio Insua Rivas, 56 - 15008 A Coruña (ES) (ver mapa
<https://goo.gl/maps/KbSUu5Pz9KArD8cD8>)
https://www.cinfo.es

CONFIDENCIALIDAD Y PROTECCIÓN DE DATOS

Este envío es *privado y confidencial*, estando destinado únicamente a la
persona a la que ha sido enviado. Si usted no es el destinatario al que ha
sido remitido, no puede copiar la información, distribuirla ni emprender
con ella ningún tipo de acción. Si cree que lo ha recibido por error, por
favor, *notifíquelo al remitente y proceda a su eliminación*.

*Información Básica de Protección de Datos. Responsable:* CINFO CONTENIDOS
INFORMATIVOS ESPECIALIZADOS, S.L. (B15757941) C/Antonio Insua Rivas
56,15008 Coruña.*Finalidad:* Inicio o mantenimiento de la relación
profesional. Envío de información, respuesta a consultas y contactos
genéricos. *Legitimación:* Consentimiento del interesado. *Destinatarios:*
No se cederán datos a terceros salvo obligación legal. *Derechos:* Tiene
derecho de acceso, oposición, limitación, supresión, oposición y
portabilidad de sus datos, mediante carta a la dirección postal indicada o
enviando un email a gdpr at cinfo.es. *Si no quiere recibir envíos comerciales
escriba a: gdpr at cinfo.es <gdpr at cinfo.es> Para más información sobre el uso
de los datos, visite:* https://www.cinfo.es/es/politica-privacidad/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20191008/3a9e4db5/attachment.html>


More information about the gdal-dev mailing list