I was finally able to find the error in my jpeg2000 plugin code. The reason for the error was that I was not reading the filename properly (basically reading NULL) and because of this I was getting segmentation faults when it tried to load images. I always assumed that the run function would automatically have the filename and never bothered to check this! I solved the problem by providing the necessary arguments in the query function.
The good thing is that the load plugin is working smoothly on the select images that I tested it on. It may be a little slow but I can definitely speed it up using row processing. I used the openjpeg library although I could have used the jasper library as well because the problem I was getting was common. But the openjpeg library is specifically geared towards jpeg2000 development and the library functions are a lot more easier to use that the jasper library. The final code is also very clean.
A screenshot of how the image was loaded is shown below.
I will be out attending a family function for the next two days and will start working on refining the current load code and then work on saving as jp2 or j2k images.
