[gdal-dev] RV: RGB Tiled - non Tiled Images

Mendizabal Vicente, Ainhoa amendizabal at indra.es
Wed Jul 2 02:32:07 EDT 2008


Hi, 

 

I was trying to generate an RGB non-tiled image from a Grey tiled Image like this:

 

            GDALAllRegister();

            

            GDALDataset *m_InputImage;

            GDALRasterBand *InputRasterBand;

 

            m_InputImage = (GDALDataset*)GDALOpen("D: \\DAT_01.001_tiled.tif", GA_ReadOnly);

 

            char **papszOptions = NULL;

            papszOptions = CSLSetNameValue(papszOptions, "TILED", "YES");

            GDALDataset *m_OutputImage = (GDALDataset*)GDALCreate(m_InputImage->GetDriver(), D:\\Remuestreo.tif", 1024, 1024, 3, GDT_Byte, papszOptions);

            GDALRasterBand *OutputRasterBand;

            

            int rowTile;

            int colTile;

            int colOff = 3;

            int rowOff = 3;

            int band;

            

            InputRasterBand = m_InputImage->GetRasterBand(1);

            unsigned char* Buffer;

            Buffer = (unsigned char *) malloc(256*256*sizeof(unsigned char));

            for(rowTile = 0; rowTile < 4; rowTile ++)

            {

                        for(colTile = 0; colTile <4; colTile++)

                        {

                                   for(band = 1; band<=3; band ++)

                                   {

 

                                               InputRasterBand->ReadBlock(colTile + colOff, rowTile + rowOff, (void*)Buffer);

                                               OutputRasterBand = m_OutputImage->GetRasterBand(band);

                                               OutputRasterBand->WriteBlock(colTile, rowTile, (void*)Buffer);

                                   }

                        }

            }

            

    GDALDataset *OutputShown2;

    OutputShown2 = m_OutputImage->GetDriver()->CreateCopy("D\\RemuestreoShown.tif", m_OutputImage, false, NULL, NULL, NULL);

            

    free(Buffer);

            

    GDALClose(m_OutputImage);

    GDALClose(OutputShown2);

 

But I could not view properly the resulting image.

 

Looking for the original problem I've tried simply to transform a RGB non-tiled Image to tiled, and then I've made it non-tiled again:

 

gdal_transform -co 'tiled=yes'    Original.tif         Tiled.tif

gdal_transform -co 'tiled=no'      Tiled.tif             Result.tif

 

but, I can't view properly the Image Result.tif. ¿What I've made wrong?

 

Thank you

 

Ainhoa

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20080702/521e0110/attachment-0001.html


More information about the gdal-dev mailing list