def createFields(self):
     values = [[], []]
     for i in (0, 1):
         yield Bits(self, "blue[]", 5)
         yield Bits(self, "green[]", 6)
         yield Bits(self, "red[]", 5)
         values[i] = [self["red[%i]" % i].value,
                      self["green[%i]" % i].value,
                      self["blue[%i]" % i].value]
     if values[0] > values[1] or self.dxt2_mode:
         values += interp_avg(values[0], values[1], 3)
     else:
         values += interp_avg(values[0], values[1], 2)
         values.append(None) # transparent
     for i in xrange(16):
         pixel = Bits(self, "pixel[%i][%i]" % divmod(i, 4), 2)
         color = values[pixel.value]
         if color is None:
             pixel._description = "Transparent"
         else:
             pixel._description = "RGB color: %s" % color_name(color, [5, 6, 5])
         yield pixel
 def createFields(self):
     values = []
     yield UInt8(self, "alpha_val[0]", "First alpha value")
     values.append(self["alpha_val[0]"].value)
     yield UInt8(self, "alpha_val[1]", "Second alpha value")
     values.append(self["alpha_val[1]"].value)
     if values[0] > values[1]:
         values += interp_avg(values[0], values[1], 7)
     else:
         values += interp_avg(values[0], values[1], 5)
         values += [0, 255]
     for i in xrange(16):
         pixel = Bits(self, "alpha[%i][%i]" % divmod(i, 4), 3)
         alpha = values[pixel.value]
         pixel._description = "Alpha value: %i" % alpha
         yield pixel