Did I find the right examples for you? yes no Crawl my project Python Jobs
All Samples(4) | Call(2) | Derive(0) | Import(2)
Makes the conversion between number and bits @param num: Number to be converted @param bitsPerComponent: Number of bits needed to represent a component @return: A tuple (status,statusContent), where statusContent is the string containing the resulting bits in case status = 0 or an error in case status = -1
def getBitsFromNum(num, bitsPerComponent = 8): ''' Makes the conversion between number and bits @param num: Number to be converted @param bitsPerComponent: Number of bits needed to represent a component @return: A tuple (status,statusContent), where statusContent is the string containing the resulting bits in case status = 0 or an error in case status = -1 ''' if not isinstance(num,int): return (-1,'num must be an integer') if not isinstance(bitsPerComponent,int): return (-1,'bitsPerComponent must be an integer') try: bitsRepresentation = bin(num) bitsRepresentation = bitsRepresentation.replace('0b','') mod = len(bitsRepresentation) % 8 if mod != 0: bitsRepresentation = '0'*(8-mod) + bitsRepresentation bitsRepresentation = bitsRepresentation[-1*bitsPerComponent:] except: return (-1,'Error in conversion from number to bits') return (0,bitsRepresentation)
import sys, zlib, lzw, struct from PDFUtils import getNumsFromBytes, getBytesFromBits, getBitsFromNum from ccitt import CCITTFax
diffPixel = colorNums[i+j] pixel[j] = (pixel[j] + diffPixel) & bitmask ret, outputBits = getBitsFromNum(pixel[j],bits) if ret == -1: return (ret,outputBits)
src/c/l/classyPDF-HEAD/peepdf_classy/PDFFilters.py classyPDF(Download)
import sys, zlib, lzw, struct from PDFUtils import getNumsFromBytes, getBytesFromBits, getBitsFromNum def decodeStream(stream, filter, parameters = {}):
diffPixel = colorNums[i+j] pixel[j] = (pixel[j] + diffPixel) & bitmask ret, outputBits = getBitsFromNum(pixel[j],bits) if ret == -1: return (ret,outputBits)