I am writing a program in python that converts raster files using gdal, and using VRT as an intermediate format. One of the things that i need to do is convert bands between different formats. I am pretty sure that you do this using Pixel Functions. Since python doesn't have this functionality, i have to use C++ for this part. I used some code from the VRT tutorial website, but it doesn't seem to work.
GDALAddDerivedBandPixelFunc("MyFirstFunction", TestFunction); typedef CPLErr (*GDALDerivedPixelFunc)(void **papoSources, int nSources, void *pData, int nXSize, int nYSize, GDALDataType eSrcType, GDALDataType eBufType, int nPixelSpace, int nLineSpace);
I implement that function with the code from http://www.gdal.org/gdal_vrttut.html, but it doesn't seem to be working. I am calling gdal_translate to do the conversion process, but it seems like the pixel function does not stay. The addpixelfunc returns a result of 0. Is there some way to write a GDAL extension to have this function be permanent?
I have been able to correctly create a pixel function and get it to work if i manually convert the file in the same C++ program as the GDALAddDerivedBandPixelFunc resides, however i am still interested in how i could make this permanent. Although it may not be needed since i might want to let the user change some numbers in the function.