void
avtImageRepresentation::GetImageFromString(unsigned char *str,
        int strLength, vtkImageData *&img, vtkFloatArray *&zbuf)
{

    int strLengthNew = 0;
    unsigned char *strNew = 0;
    if (CDecompressDataString(str, strLength, &strNew, &strLengthNew,
                              &timeToCompress, &timeToDecompress,
                              &compressionRatio))
    {
        delete [] str;
        str = strNew;
        strLength = strLengthNew;

        // update the object, too
        asChar = strNew;
        asCharLength = strLengthNew;
    }

    // read the string assuming its just an image
    vtkStructuredPointsReader *reader = vtkStructuredPointsReader::New();
    vtkCharArray *charArray = vtkCharArray::New();
    int iOwnIt = 1;  // 1 means we own it -- you don't delete it.
    charArray->SetArray((char *) str, strLength, iOwnIt);
    reader->SetReadFromInputString(1);
    reader->SetInputArray(charArray);
    reader->Update();

    if (img)
        img->Delete();

    img = reader->GetOutput();
    img->SetScalarType(VTK_UNSIGNED_CHAR, img->GetInformation());
    img->Register(NULL);

    reader->Delete();
    charArray->Delete();

    // If there is a "zbuffer" point data array, then get it too
    if (zbuf)
        zbuf->Delete();

    zbuf = dynamic_cast<vtkFloatArray*>(
        img->GetPointData()->GetArray("zbuffer"));

    if (zbuf)
    {
        zbuf->Register(NULL);
        img->GetPointData()->RemoveArray("zbuffer");
    }
}
void avtImageRepresentation::GetImageFromString(unsigned char *str,
        int strLength, vtkImageData *&img, float *&zbuffer)
{

    int strLengthNew = 0;
    unsigned char *strNew = 0;
    if (CDecompressDataString(str, strLength, &strNew, &strLengthNew,
                              &timeToCompress, &timeToDecompress,
                              &compressionRatio))
    {
        delete [] str;
        str = strNew;
        strLength = strLengthNew;

        // update the object, too
        asChar = strNew;
        asCharLength = strLengthNew;
    }

    // read the string assuming its just an image
    vtkStructuredPointsReader *reader = vtkStructuredPointsReader::New();
    vtkCharArray *charArray = vtkCharArray::New();
    int iOwnIt = 1;  // 1 means we own it -- you don't delete it.
    charArray->SetArray((char *) str, strLength, iOwnIt);
    reader->SetReadFromInputString(1);
    reader->SetInputArray(charArray);
    reader->Update();
    img = reader->GetOutput();
    img->SetScalarType(VTK_UNSIGNED_CHAR, img->GetInformation());
    img->Register(NULL);
    //  calling SetSource sets' PipelineInformation to NULL, and then
    //  vtkImageData no longer knows its scalar data type, and who knows
    //  what else.
    //img->SetSource(NULL);
    reader->Delete();
    charArray->Delete();

    // If there is a "zbuffer" point data array, then get it too
    vtkDataArray *zArray = img->GetPointData()->GetArray("zbuffer");
    if (zArray)
    {
       int size = zArray->GetSize();
       zbuffer = new float[size];
       memcpy(zbuffer, zArray->GetVoidPointer(0), size * sizeof(float));
       zbufferRef   = new int(1);

       // remove the zbuffer data from the vtkImageData object 
       img->GetPointData()->RemoveArray("zbuffer");
    }
}