def flateDecode(stream, parameters):
 decodedStream = ''
 try:
  decodedStream = zlib.decompress(stream)
 except:
  return ((-1), 'Error decompressing string')
 if ((parameters == None) or (parameters == {})):
  return (0, decodedStream)
 else:
  if parameters.has_key('/Predictor'):
   predictor = parameters['/Predictor'].getRawValue()
  else:
   predictor = 1
  if parameters.has_key('/Columns'):
   columns = parameters['/Columns'].getRawValue()
  else:
   columns = 1
  if parameters.has_key('/Colors'):
   colors = parameters['/Colors'].getRawValue()
   if (colors < 1):
    colors = 1
  else:
   colors = 1
  if parameters.has_key('/BitsPerComponent'):
   bits = parameters['/BitsPerComponent'].getRawValue()
   if (bits not in [1, 2, 4, 8, 16]):
    bits = 8
  else:
   bits = 8
  if ((predictor != None) and (predictor != 1)):
   ret = post_prediction(decodedStream, predictor, columns, colors, bits)
   return ret
  else:
   return (0, decodedStream)

def flateDecode ( stream , parameters ) : decodedStream = '' try : decodedStream = zlib . decompress ( stream ) except : return ( ( - 1 ) , 'Error decompressing string' ) if ( ( parameters == None ) or ( parameters == { } ) ) : return ( 0 , decodedStream ) else : if parameters . has_key ( '/Predictor' ) : predictor = parameters [ '/Predictor' ] . getRawValue ( ) else : predictor = 1 if parameters . has_key ( '/Columns' ) : columns = parameters [ '/Columns' ] . getRawValue ( ) else : columns = 1 if parameters . has_key ( '/Colors' ) : colors = parameters [ '/Colors' ] . getRawValue ( ) if ( colors < 1 ) : colors = 1 else : colors = 1 if parameters . has_key ( '/BitsPerComponent' ) : bits = parameters [ '/BitsPerComponent' ] . getRawValue ( ) if ( bits not in [ 1 , 2 , 4 , 8 , 16 ] ) : bits = 8 else : bits = 8 if ( ( predictor != None ) and ( predictor != 1 ) ) : ret = post_prediction ( decodedStream , predictor , columns , colors , bits ) return ret else : return ( 0 , decodedStream )
method to decode streams using the flate algorithm .