Changeset 479 for pkpgcounter/trunk/pkpgpdls
- Timestamp:
- 09/30/07 11:22:07 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/pclxl.py
r478 r479 95 95 def beginPage(self, nextpos) : 96 96 """Indicates the beginning of a new page, and extracts media information.""" 97 # self.logdebug("BeginPage at %x" % nextpos) 97 98 self.pagecount += 1 98 99 … … 181 182 def endPage(self, nextpos) : 182 183 """Indicates the end of a page.""" 184 # self.logdebug("EndPage at %x" % nextpos) 183 185 pos3 = nextpos - 3 184 186 minfile = self.minfile … … 199 201 """Changes the color space.""" 200 202 if self.minfile[nextpos-4:nextpos-1] == self.RGBColorSpace : # TODO : doesn't seem to handle all cases ! 201 self.iscolor = 1203 self.iscolor = True 202 204 return 0 203 205 … … 224 226 225 227 def array_32(self, nextpos) : 226 """Handles 32 bits arrays.""" 227 return self.array_Generic(nextpos, 4) 228 """Handles 32 bits arrays and Canon ImageRunner tags.""" 229 minfile = self.minfile 230 irtag = minfile[nextpos-1:nextpos+3] 231 if irtag in (self.imagerunnermarker1, self.imagerunnermarker2) : 232 # This is the beginning of a Canon ImageRunner tag 233 # self.logdebug("Canon ImageRunner tag at %x" % (nextpos-1)) 234 codop = minfile[nextpos+1:nextpos+3] 235 length = unpack(">H", minfile[nextpos+7:nextpos+9])[0] 236 # self.logdebug("Canon ImageRunner block length=%04x" % length) 237 toskip = 19 238 if irtag != self.imagerunnermarker2 : 239 toskip += length 240 # self.logdebug("Canon ImageRunner skip until %x" % (nextpos+toskip)) 241 return toskip 242 else : 243 # This is a normal PCLXL array 244 return self.array_Generic(nextpos, 4) 228 245 229 246 def embeddedDataSmall(self, nextpos) : … … 234 251 """Handle normal amounts of data.""" 235 252 return 4 + unpack(self.unpackLong, self.minfile[nextpos:nextpos+4])[0] 253 254 def skipHPPCLXL(self, nextpos) : 255 """Skip the 'HP-PCL XL' statement if needed.""" 256 minfile = self.minfile 257 if nextpos and (minfile[nextpos:nextpos+11] == " HP-PCL XL;") : 258 pos = nextpos 259 while minfile[pos] != '\n' : 260 pos += 1 261 length = (pos - nextpos + 1) 262 # self.logdebug("Skip HP PCLXL statement until %x" % (nextpos + length)) 263 return length 264 else : 265 return 0 236 266 237 267 def littleEndian(self, nextpos) : … … 240 270 self.unpackShort = self.unpackType[2] 241 271 self.unpackLong = self.unpackType[4] 242 return 0 272 # self.logdebug("LittleEndian at %x" % (nextpos - 1)) 273 return self.skipHPPCLXL(nextpos) 243 274 244 275 def bigEndian(self, nextpos) : … … 247 278 self.unpackShort = self.unpackType[2] 248 279 self.unpackLong = self.unpackType[4] 249 return 0 280 # self.logdebug("BigEndian at %x" % (nextpos - 1)) 281 return self.skipHPPCLXL(nextpos) 250 282 251 283 def reservedForFutureUse(self, nextpos) : … … 335 367 xl_refsup30r089.pdf 336 368 """ 337 self.iscolor = None 369 370 infileno = self.infile.fileno() 371 self.minfile = minfile = mmap.mmap(infileno, os.fstat(infileno)[6], prot=mmap.PROT_READ, flags=mmap.MAP_SHARED) 372 373 self.iscolor = False 374 338 375 found = False 339 376 while not found : … … 349 386 elif endian == 0x28 : 350 387 self.bigEndian(0) 351 # elif endian == 0x27 : # TODO : This is the ESC code : parse it for PJL statements !388 # elif endian == 0x27 : # TODO : This is the ASCII binding code : what does it do exactly ? 352 389 # 353 390 else : … … 446 483 self.tags[0xcb] = self.array_16 # sint16_array 447 484 self.tags[0xcc] = self.array_32 # sint32_array 448 self.tags[0xcd] = self.array_32 # real32_array 485 self.tags[0xcd] = self.array_32 # real32_array and unfortunately Canon ImageRunner 449 486 450 487 self.tags[0xce] = self.reservedForFutureUse # reserved … … 525 562 } 526 563 527 infileno = self.infile.fileno() 564 # Markers for Canon ImageRunner printers 565 self.imagerunnermarker1 = chr(0xcd) + chr(0xca) + chr(0x10) + chr(0x00) 566 self.imagerunnermarker2 = chr(0xcd) + chr(0xca) + chr(0x10) + chr(0x02) 567 528 568 self.pages = { 0 : { "copies" : 1, 529 569 "orientation" : "Default", … … 534 574 } 535 575 } 536 self.minfile = minfile = mmap.mmap(infileno, os.fstat(infileno)[6], prot=mmap.PROT_READ, flags=mmap.MAP_SHARED)537 576 tags = self.tags 538 577 self.pagecount = 0