In RawRasterBand::IWriteBlock there is a test for complex data type when copying into the buffer, but no test for complex data at the end of the method when reaccessing the buffer. This looks like a simple fix...unless I don't understand the purpose of rawdataset.cpp
/* -------------------------------------------------------------------- */
/* Byte swap (if necessary) back into disk order before writing. */
/* -------------------------------------------------------------------- */
if( !bNativeOrder && eDataType != GDT_Byte )
{
if( GDALDataTypeIsComplex( eDataType ) )
{
...
...
...
/* -------------------------------------------------------------------- */
/* Byte swap (if necessary) back into machine order so the */
/* buffer is still usable for reading purposes. */
/* -------------------------------------------------------------------- */
if( !bNativeOrder && eDataType != GDT_Byte )
{
so need to added the following:
if( GDALDataTypeIsComplex( eDataType ) )
{
int nWordSize;
nWordSize = GDALGetDataTypeSize(eDataType)/16;
GDALSwapWords( pLineBuffer, nWordSize, nBlockXSize, nPixelOffset );
GDALSwapWords( ((GByte *) pLineBuffer)+nWordSize,
nWordSize, nBlockXSize, nPixelOffset );
}