comparison tools/libgfx.c @ 2100:81fb21dd3265

Add dmGetNPlanesFromNColors() and use it.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 05 Mar 2019 15:09:18 +0200
parents e38705223ce4
children da886b8cbb09
comparison
equal deleted inserted replaced
2099:dac89484f143 2100:81fb21dd3265
86 86
87 if (ctx->outBitCount > 0) 87 if (ctx->outBitCount > 0)
88 return dmPutBits(ctx, 0, 8 - ctx->outBitCount); 88 return dmPutBits(ctx, 0, 8 - ctx->outBitCount);
89 89
90 return DMERR_OK; 90 return DMERR_OK;
91 }
92
93
94 int dmGetNPlanesFromNColors(const int ncolors)
95 {
96 if (ncolors <= 0)
97 return -1;
98
99 for (int n = 8; n >= 0;)
100 {
101 if ((ncolors - 1) & (1 << n))
102 return n + 1;
103 else
104 n--;
105 }
106
107 return -2;
91 } 108 }
92 109
93 110
94 BOOL dmCompareColor(const DMColor *c1, const DMColor *c2, const BOOL alpha) 111 BOOL dmCompareColor(const DMColor *c1, const DMColor *c2, const BOOL alpha)
95 { 112 {