Lines Matching refs:bitdepth

325                  bitdepth=8,
350 bitdepth
376 `bitdepth` specifies the bit depth of the source pixel values.
378 ``2**bitdepth-1``. For example, 8-bit images have values
380 1,2,4,8, or 16. When `bitdepth` is not one of these values,
394 argument is specified) the `bitdepth` argument must match one of
398 `bitdepth` argument into service for this.)
405 and the `bitdepth` argument specifies the size of these indexes
528 warnings.warn('please use bitdepth instead of bytes_per_sample',
533 bitdepth = int(8*bytes_per_sample)
535 if not isinteger(bitdepth) or bitdepth < 1 or 16 < bitdepth:
536 raise ValueError("bitdepth (%r) must be a postive integer <= 16" %
537 bitdepth)
541 if bitdepth not in (1,2,4,8):
542 raise ValueError("with palette, bitdepth must be 1, 2, 4, or 8")
552 if bitdepth not in (8,16):
553 targetbitdepth = (8,16)[bitdepth > 8]
554 self.rescale = (bitdepth, targetbitdepth)
555 bitdepth = targetbitdepth
560 if bitdepth not in (1,2,4,8,16):
561 if bitdepth > 8:
563 elif bitdepth == 3:
566 assert bitdepth in (5,6,7)
568 self.rescale = (bitdepth, targetbitdepth)
569 bitdepth = targetbitdepth
572 if bitdepth < 8 and (alpha or not greyscale and not palette):
574 "bitdepth < 8 only permitted with greyscale or palette")
575 if bitdepth > 8 and palette:
593 self.bitdepth = int(bitdepth)
604 # :todo: fix for bitdepth < 8
605 self.psize = (self.bitdepth/8) * self.planes
641 fmt = 'BH'[self.bitdepth > 8]
677 self.bitdepth, self.color_type,
729 # Choose an extend function based on the bitdepth. The extend
733 if self.bitdepth == 8 or packed:
735 elif self.bitdepth == 16:
742 assert self.bitdepth < 8
744 spb = int(8/self.bitdepth)
755 (x << self.bitdepth) + y, e), l)
863 (self.bitdepth/8) * self.color_planes *
876 (self.bitdepth/8) * self.color_planes *
880 (self.bitdepth/8) *
883 (self.bitdepth/8) * self.color_planes,
884 (self.bitdepth/8))
897 per value is implied by the image `bitdepth`.
903 if self.bitdepth > 8:
904 assert self.bitdepth == 16
940 fmt = 'BH'[self.bitdepth > 8]
1127 datatype (but if *mode* specifies a bitdepth then that is used
1145 bitdepth
1162 bitdepth = None
1171 bitdepth = int(mode[1])
1178 # Get bitdepth from *mode* if possible.
1179 if bitdepth:
1180 if info.get('bitdepth') and bitdepth != info['bitdepth']:
1181 raise Error("mode bitdepth (%d) should match info bitdepth (%d)." %
1182 (bitdepth, info['bitdepth']))
1183 info['bitdepth'] = bitdepth
1220 # We may also need the first row to derive width and bitdepth.
1241 if 'bitdepth' not in info:
1248 bitdepth = 8 * testelement.itemsize
1252 bitdepth = 8
1257 bitdepth = 1
1259 bitdepth = 8 * dtype.itemsize
1260 info['bitdepth'] = bitdepth
1262 for thing in 'width height bitdepth greyscale alpha'.split():
1568 fmt = 'BH'[self.bitdepth > 8]
1616 if self.bitdepth == 8:
1618 if self.bitdepth == 16:
1621 assert self.bitdepth < 8
1624 spb = 8//self.bitdepth
1626 mask = 2**self.bitdepth - 1
1627 shifts = map(self.bitdepth.__mul__, reversed(range(spb)))
1639 if self.bitdepth == 8:
1641 if self.bitdepth == 16:
1645 assert self.bitdepth < 8
1649 spb = 8//self.bitdepth
1651 mask = 2**self.bitdepth - 1
1652 shifts = map(self.bitdepth.__mul__, reversed(range(spb)))
1756 (self.width, self.height, self.bitdepth, self.color_type,
1761 if self.bitdepth not in (1,2,4,8,16):
1762 raise Error("invalid bit depth %d" % self.bitdepth)
1768 if ((self.color_type & 1 and self.bitdepth > 8) or
1769 (self.bitdepth < 8 and self.color_type not in (0,3))):
1773 % (self.bitdepth, self.color_type))
1798 self.psize = float(self.bitdepth)/float(8) * planes
1818 if len(data) > (2**self.bitdepth)*3:
1919 arraycode = 'BH'[self.bitdepth>8]
1927 for attr in 'greyscale alpha planes bitdepth interlace'.split():
1953 arraycode = 'BH'[meta['bitdepth']>8]
2029 meta['bitdepth'] = 8
2045 maxval = 2**meta['bitdepth']-1
2049 typecode = 'BH'[meta['bitdepth']>8]
2068 if targetbitdepth > meta['bitdepth']:
2069 raise Error('sBIT chunk %r exceeds bitdepth %d' %
2070 (sbit,self.bitdepth))
2073 if targetbitdepth == meta['bitdepth']:
2076 shift = meta['bitdepth'] - targetbitdepth
2077 meta['bitdepth'] = targetbitdepth
2091 sourcemaxval = 2**info['bitdepth']-1
2092 del info['bitdepth']
2104 maxval = 2**meta['bitdepth'] - 1
2107 meta['bitdepth'] = targetbitdepth
2166 typecode = 'BH'[meta['bitdepth'] > 8]
2188 typecode = 'BH'[meta['bitdepth'] > 8]
2189 maxval = 2**meta['bitdepth'] - 1
2516 w = Writer(15, 17, greyscale=True, bitdepth=n, chunk_limit=99)
2531 w = Writer(1, 4, greyscale=True, bitdepth=2)
2546 w = Writer(1, 4, bitdepth=2, palette=[a,b,c])
2561 w = Writer(3, 3, bitdepth=4, palette=[a,b,c,d,e])
2635 x=x, y=y, bitdepth=it.bitdepth,
2643 x=x, y=y, bitdepth=it.bitdepth,
2663 self.assertEqual(r.bitdepth, 2)
2685 """Create an LA image with bitdepth 4."""
2687 greyscale=True, alpha=True, bitdepth=4)
2712 """Test that bitdepth can be used to fiddle with pallete image."""
2716 info['bitdepth'] = 8
2753 w = Writer(8, 8, greyscale=True, bitdepth=1, transparent=transparent)
2759 self.assertEqual(meta['bitdepth'], 1)
2772 w = Writer(16, 2, greyscale=True, alpha=False, bitdepth=1)
2890 greyscale=True, alpha=False, bitdepth=16)
2902 greyscale=True, alpha=False, bitdepth=8)
2914 greyscale=True, alpha=False, bitdepth=1)
3680 bitdepth = meta['bitdepth']
3681 maxval = 2**bitdepth - 1
3826 bitdepth = mi+1
3829 bitdepth=bitdepth,