1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
# include "bitmapConfig.h"
# include "bmintern.h"
# include <string.h>
# include <appDebugon.h>
/************************************************************************/
/* */
/* Color administration. */
/* */
/************************************************************************/
void bmSetCalculatedShifts( ColorAllocator * ca,
unsigned long redMask,
unsigned long greenMask,
unsigned long blueMask )
{
ca->caRedPixelShift= 0;
while( ! ( redMask & 0x1 ) )
{ ca->caRedPixelShift++; redMask= redMask >> 1; }
ca->caRedMask= redMask;
ca->caRedApproxShift= 8;
while( redMask & 0x1 )
{ ca->caRedApproxShift--; redMask= redMask >> 1; }
ca->caGreenPixelShift= 0;
while( ! ( greenMask & 0x1 ) )
{ ca->caGreenPixelShift++; greenMask= greenMask >> 1; }
ca->caGreenMask= greenMask;
ca->caGreenApproxShift= 8;
while( greenMask & 0x1 )
{ ca->caGreenApproxShift--; greenMask= greenMask >> 1; }
ca->caBluePixelShift= 0;
while( ! ( blueMask & 0x1 ) )
{ ca->caBluePixelShift++; blueMask= blueMask >> 1; }
ca->caBlueMask= blueMask;
ca->caBlueApproxShift= 8;
while( blueMask & 0x1 )
{ ca->caBlueApproxShift--; blueMask= blueMask >> 1; }
return;
}
void bmCleanColorAllocator( ColorAllocator * ca )
{
if ( ca->caColors )
{ free( ca->caColors ); ca->caColors= (AllocatorColor *)0; }
ca->caColorCount= 0;
return;
}
void bmInitColorAllocator( ColorAllocator * ca )
{
int i;
ca->caColorCount= 0;
ca->caColors= (AllocatorColor *)0;
for ( i= 0; i < 64; i++ )
{ ca->ca222Colors[i].acAllocated= AC_CALCULATED; }
ca->caAllocationType= AC_UNALOCATED;
ca->caSystemPrivate= (void *)0;
ca->caSystemAllocator= (SystemAllocator)0;
return;
}
|