I am using the below code but its seems that the moment I try to save the pixel all the pixel data get lost and the file size get reeduced, any chance that the saveFile function
did cause this loss, if yes how can I prevent them
Large element values like Pixel Data are only loaded on demand, i.e. if you write to the same filename, the Pixel Data has not been loaded yet from the input file and is, therefore, stored with 0 byte length to the output file.
One solution is to use different filenames for input and output file. Another solution is to load the Pixel Data into main memory before calling saveFile(). The latter is done by calling loadAllDataIntoMemory() on the dataset.
Alternatively, you could specify a larger value for the "maxReadLength" parameter of the loadFile() method, i.e. a value that is larger than the length of the Pixel Data element.