1497 alp = (rgb>>24)&0xff; 1498 if (nBits[3] == 8) { 1499 intpixel[3] = alp; 1500 } 1501 else { 1502 intpixel[3] = (int) 1503 (alp * (1.0f / 255.0f) * ((1<<nBits[3]) - 1) + 0.5f); 1504 } 1505 if (isAlphaPremultiplied) { 1506 factor *= (alp * (1.0f / 255.0f)); 1507 precision = -1; // force component calculations below 1508 } 1509 } 1510 if (nBits[0] == precision) { 1511 intpixel[0] = red; 1512 } 1513 else { 1514 intpixel[0] = (int) (red * factor * ((1<<nBits[0]) - 1) + 0.5f); 1515 } 1516 if (nBits[1] == precision) { 1517 intpixel[1] = (int)(grn); 1518 } 1519 else { 1520 intpixel[1] = (int) (grn * factor * ((1<<nBits[1]) - 1) + 0.5f); 1521 } 1522 if (nBits[2] == precision) { 1523 intpixel[2] = (int)(blu); 1524 } 1525 else { 1526 intpixel[2] = (int) (blu * factor * ((1<<nBits[2]) - 1) + 0.5f); 1527 } 1528 } else if (is_LinearGray_stdScale) { 1529 red = fromsRGB8LUT16[red] & 0xffff; 1530 grn = fromsRGB8LUT16[grn] & 0xffff; 1531 blu = fromsRGB8LUT16[blu] & 0xffff; 1532 float gray = ((0.2125f * red) + 1533 (0.7154f * grn) + 1534 (0.0721f * blu)) / 65535.0f; 1535 if (supportsAlpha) { 1536 alp = (rgb>>24) & 0xff; 1537 if (nBits[1] == 8) { 1538 intpixel[1] = alp; 1539 } else { 1540 intpixel[1] = (int) (alp * (1.0f / 255.0f) * 1541 ((1 << nBits[1]) - 1) + 0.5f); 1542 } 1543 if (isAlphaPremultiplied) { | 1497 alp = (rgb>>24)&0xff; 1498 if (nBits[3] == 8) { 1499 intpixel[3] = alp; 1500 } 1501 else { 1502 intpixel[3] = (int) 1503 (alp * (1.0f / 255.0f) * ((1<<nBits[3]) - 1) + 0.5f); 1504 } 1505 if (isAlphaPremultiplied) { 1506 factor *= (alp * (1.0f / 255.0f)); 1507 precision = -1; // force component calculations below 1508 } 1509 } 1510 if (nBits[0] == precision) { 1511 intpixel[0] = red; 1512 } 1513 else { 1514 intpixel[0] = (int) (red * factor * ((1<<nBits[0]) - 1) + 0.5f); 1515 } 1516 if (nBits[1] == precision) { 1517 intpixel[1] = grn; 1518 } 1519 else { 1520 intpixel[1] = (int) (grn * factor * ((1<<nBits[1]) - 1) + 0.5f); 1521 } 1522 if (nBits[2] == precision) { 1523 intpixel[2] = blu; 1524 } 1525 else { 1526 intpixel[2] = (int) (blu * factor * ((1<<nBits[2]) - 1) + 0.5f); 1527 } 1528 } else if (is_LinearGray_stdScale) { 1529 red = fromsRGB8LUT16[red] & 0xffff; 1530 grn = fromsRGB8LUT16[grn] & 0xffff; 1531 blu = fromsRGB8LUT16[blu] & 0xffff; 1532 float gray = ((0.2125f * red) + 1533 (0.7154f * grn) + 1534 (0.0721f * blu)) / 65535.0f; 1535 if (supportsAlpha) { 1536 alp = (rgb>>24) & 0xff; 1537 if (nBits[1] == 8) { 1538 intpixel[1] = alp; 1539 } else { 1540 intpixel[1] = (int) (alp * (1.0f / 255.0f) * 1541 ((1 << nBits[1]) - 1) + 0.5f); 1542 } 1543 if (isAlphaPremultiplied) { |