public long updateData(LodResource lodResourceDataSource, OutputStream outputStream, long dataOffset)
         throws IOException
    {
        TGADataProducer tgaDataProducer = (TGADataProducer)lodResourceDataSource;

        byte uncompactedData[] = lodResourceDataSource.getData();
//      System.out.println(getName() + "- DS uncompacted data size: " + uncompactedData.length);
        
        byte zeroCompressionTableData[] = new byte[ZERO_COMPRESSION_TABLE_DATA_SIZE * tgaDataProducer.getByteHeight()];
        byte uncompressedData[] = zeroCompressDataIntoTable(tgaDataProducer.getByteWidth(), tgaDataProducer.getByteHeight(), uncompactedData, zeroCompressionTableData);
        
//      System.out.println(getName() + "- DS uncompressed data size: " + uncompressedData.length);
//      System.out.println(getName() + "- DS zeroCompressionTabledata size: " + zeroCompressionTableData.length);
        
         byte compressedData[] = theLodFileExtractor.compress(uncompressedData);

         byte smallestData[] = null;
         int uncompressedDataLengthSpecifier;
        
         if (uncompressedData.length > compressedData.length)
         {
             smallestData = compressedData;
             uncompressedDataLengthSpecifier = uncompressedData.length;
         }
         else
         {
             smallestData = uncompressedData;
             uncompressedDataLengthSpecifier = 0;
         }

//       System.out.println(getName() + "- rawdataLength: " + smallestData.length);
         
         int sourcePalette[] = tgaDataProducer.getPalette();

         if (null == sourcePalette)
             throw new RuntimeException("No source palette");

         // IMPLEMENT: verify that palette matches known palette number or create new palette resource
         // for now, assume palette doesn't change
         long paletteNumber = getPaletteNumber();

         int originalPalette[];
		try {
			originalPalette = getPalette();
		} catch (IOException ioException) {
			if (ioException.getCause() instanceof NoSuchEntryException)
			{
				ioException.printStackTrace();
				
				// Meaningless image, but we can continue past it -- generate unique value for every palette point.
				originalPalette = new int[768];
				for (int i = 0; i < originalPalette.length; ++i)
				{
					originalPalette[i] = i;
				}
			}
			else
			{
				throw ioException;
			}
		}
         
         for (int i = 0 ; i < sourcePalette.length ; i++) {
             if (sourcePalette[i] != originalPalette[i])
                 System.err.println(getName() + ": Warning: palette doesn't match original palette for sprite!");
             	// IMPLEMENT: throw harder error
         }

//       System.out.println("palette: " + sourcePalette.length);

         long newDataOffset = updateDataHeader(lodResourceDataSource, outputStream, dataOffset, uncompressedDataLengthSpecifier, paletteNumber);
        
         outputStream.write(zeroCompressionTableData);
         outputStream.write(smallestData);

         long newOffset = newDataOffset + zeroCompressionTableData.length + smallestData.length;

//       System.out.println(getName() + " - nextoffset: " + newOffset);

         return newOffset;
     }