This function simply counts how many contiguous bits are in the mask.
| 1763 | |
| 1764 | // This function simply counts how many contiguous bits are in the mask. |
| 1765 | ILuint CountBitsFromMask(ILuint Mask) |
| 1766 | { |
| 1767 | ILuint i, TestBit = 0x01, Count = 0; |
| 1768 | ILboolean FoundBit = IL_FALSE; |
| 1769 | |
| 1770 | for (i = 0; i < 32; i++, TestBit <<= 1) { |
| 1771 | if (Mask & TestBit) { |
| 1772 | if (!FoundBit) |
| 1773 | FoundBit = IL_TRUE; |
| 1774 | Count++; |
| 1775 | } |
| 1776 | else if (FoundBit) |
| 1777 | return Count; |
| 1778 | } |
| 1779 | |
| 1780 | return Count; |
| 1781 | } |
| 1782 | |
| 1783 | |
| 1784 | // Same as DecompressARGB, but it works on images with more than 8 bits |