16df26cacSmrg/* ********************************************************** 26df26cacSmrg * Copyright (C) 1999-2001 VMware, Inc. 36df26cacSmrg * All Rights Reserved 46df26cacSmrg * **********************************************************/ 56df26cacSmrg#ifdef VMX86_DEVEL 66df26cacSmrgchar rcsId_bits2pixels[] = "Id: bits2pixels.c,v 1.6 2001/01/26 23:32:15 yoel Exp $"; 76df26cacSmrg#else 86df26cacSmrg#define FILECODE "F(814)" 96df26cacSmrg#endif 106df26cacSmrg 116df26cacSmrg#ifdef HAVE_CONFIG_H 126df26cacSmrg#include "config.h" 136df26cacSmrg#endif 146df26cacSmrg 156df26cacSmrg/* 166df26cacSmrg * bits2pixels.c -- 176df26cacSmrg * 186df26cacSmrg * Emulation routines to convert bitmaps to pixmaps 196df26cacSmrg */ 206df26cacSmrg 216df26cacSmrg#include "vm_basic_types.h" 226df26cacSmrg#include "bits2pixels.h" 236df26cacSmrg 246df26cacSmrg 256df26cacSmrg/* 266df26cacSmrg * Local functions 276df26cacSmrg */ 286df26cacSmrg 296df26cacSmrgstatic void RasterBitsToPixels8(uint8 *bits, uint32 bits_increment, 306df26cacSmrg uint8 *pix, uint32 pix_increment, 316df26cacSmrg uint32 width, uint32 height, uint32 fg, uint32 bg); 326df26cacSmrg 336df26cacSmrgstatic void RasterBitsToPixels16(uint8 *bits, uint32 bits_increment, 346df26cacSmrg uint8 *pix, uint32 pix_increment, 356df26cacSmrg uint32 width, uint32 height, uint32 fg, uint32 bg); 366df26cacSmrg 376df26cacSmrgstatic void RasterBitsToPixels24(uint8 *bits, uint32 bits_increment, 386df26cacSmrg uint8 *pix, uint32 pix_increment, 396df26cacSmrg uint32 width, uint32 height, uint32 fg, uint32 bg); 406df26cacSmrg 416df26cacSmrgstatic void RasterBitsToPixels32(uint8 *bits, uint32 bits_increment, 426df26cacSmrg uint8 *pix, uint32 pix_increment, 436df26cacSmrg uint32 width, uint32 height, uint32 fg, uint32 bg); 446df26cacSmrg 456df26cacSmrg 466df26cacSmrg/* 476df26cacSmrg *---------------------------------------------------------------------- 486df26cacSmrg * 496df26cacSmrg * vmwareRaster_BitsToPixels -- 506df26cacSmrg * 516df26cacSmrg * Convert a bitmap to a pixmap, converting 1 bits to the foreground 526df26cacSmrg * color (fg) and 0 bits to the background color (bg). 536df26cacSmrg * 546df26cacSmrg * Results: 556df26cacSmrg * Pixmap filled with pixels 566df26cacSmrg * 576df26cacSmrg * Side effects: 586df26cacSmrg * None 596df26cacSmrg * 606df26cacSmrg *---------------------------------------------------------------------- 616df26cacSmrg */ 626df26cacSmrg 636df26cacSmrgvoid 646df26cacSmrgvmwareRaster_BitsToPixels(uint8 *bits, uint32 bits_increment, 656df26cacSmrg uint8 *pix, uint32 pix_increment, int bytes_per_pixel, 666df26cacSmrg uint32 width, uint32 height, uint32 fg, uint32 bg) 676df26cacSmrg{ 686df26cacSmrg switch (bytes_per_pixel) { 696df26cacSmrg case 1: 706df26cacSmrg RasterBitsToPixels8(bits, bits_increment, pix, pix_increment, 716df26cacSmrg width, height, fg, bg); 726df26cacSmrg break; 736df26cacSmrg 746df26cacSmrg case 2: 756df26cacSmrg RasterBitsToPixels16(bits, bits_increment, pix, pix_increment, 766df26cacSmrg width, height, fg, bg); 776df26cacSmrg break; 786df26cacSmrg 796df26cacSmrg case 3: 806df26cacSmrg RasterBitsToPixels24(bits, bits_increment, pix, pix_increment, 816df26cacSmrg width, height, fg, bg); 826df26cacSmrg break; 836df26cacSmrg 846df26cacSmrg case 4: 856df26cacSmrg RasterBitsToPixels32(bits, bits_increment, pix, pix_increment, 866df26cacSmrg width, height, fg, bg); 876df26cacSmrg break; 886df26cacSmrg } 896df26cacSmrg} 906df26cacSmrg 916df26cacSmrg 926df26cacSmrg/* 936df26cacSmrg *---------------------------------------------------------------------- 946df26cacSmrg * 956df26cacSmrg * RasterBitsToPixels8 -- 966df26cacSmrg * 976df26cacSmrg * Convert a bitmap to a pixmap, converting 1 bits to the foreground 986df26cacSmrg * color (fg) and 0 bits to the background color (bg), for an 8-bit 996df26cacSmrg * pixmap 1006df26cacSmrg * 1016df26cacSmrg * Results: 1026df26cacSmrg * Pixmap filled with pixels 1036df26cacSmrg * 1046df26cacSmrg * Side effects: 1056df26cacSmrg * None 1066df26cacSmrg * 1076df26cacSmrg *---------------------------------------------------------------------- 1086df26cacSmrg */ 1096df26cacSmrg 1106df26cacSmrgvoid 1116df26cacSmrgRasterBitsToPixels8(uint8 *bits, uint32 bits_increment, 1126df26cacSmrg uint8 *pix, uint32 pix_increment, 1136df26cacSmrg uint32 width, uint32 height, uint32 fg, uint32 bg) 1146df26cacSmrg{ 1156df26cacSmrg uint8 *lpix, *lbits; 1166df26cacSmrg int i, j; 1176df26cacSmrg uint32 expbits = 0; /* Bits to be expanded */ 1186df26cacSmrg 1196df26cacSmrg for (i=0; i<height; i++) { 1206df26cacSmrg lpix = pix; 1216df26cacSmrg lbits = bits; 1226df26cacSmrg for (j = width ; j > 0; j -= 4) { 1236df26cacSmrg expbits = (*lbits >> 4) & 0x0f; 1246df26cacSmrg 1256df26cacSmrg if (j < 4) 1266df26cacSmrg break; 1276df26cacSmrg 1286df26cacSmrg switch (expbits) { 1296df26cacSmrg case 0: 1306df26cacSmrg *lpix++ = bg; 1316df26cacSmrg *lpix++ = bg; 1326df26cacSmrg *lpix++ = bg; 1336df26cacSmrg *lpix++ = bg; 1346df26cacSmrg break; 1356df26cacSmrg case 1: 1366df26cacSmrg *lpix++ = bg; 1376df26cacSmrg *lpix++ = bg; 1386df26cacSmrg *lpix++ = bg; 1396df26cacSmrg *lpix++ = fg; 1406df26cacSmrg break; 1416df26cacSmrg case 2: 1426df26cacSmrg *lpix++ = bg; 1436df26cacSmrg *lpix++ = bg; 1446df26cacSmrg *lpix++ = fg; 1456df26cacSmrg *lpix++ = bg; 1466df26cacSmrg break; 1476df26cacSmrg case 3: 1486df26cacSmrg *lpix++ = bg; 1496df26cacSmrg *lpix++ = bg; 1506df26cacSmrg *lpix++ = fg; 1516df26cacSmrg *lpix++ = fg; 1526df26cacSmrg break; 1536df26cacSmrg case 4: 1546df26cacSmrg *lpix++ = bg; 1556df26cacSmrg *lpix++ = fg; 1566df26cacSmrg *lpix++ = bg; 1576df26cacSmrg *lpix++ = bg; 1586df26cacSmrg break; 1596df26cacSmrg case 5: 1606df26cacSmrg *lpix++ = bg; 1616df26cacSmrg *lpix++ = fg; 1626df26cacSmrg *lpix++ = bg; 1636df26cacSmrg *lpix++ = fg; 1646df26cacSmrg break; 1656df26cacSmrg case 6: 1666df26cacSmrg *lpix++ = bg; 1676df26cacSmrg *lpix++ = fg; 1686df26cacSmrg *lpix++ = fg; 1696df26cacSmrg *lpix++ = bg; 1706df26cacSmrg break; 1716df26cacSmrg case 7: 1726df26cacSmrg *lpix++ = bg; 1736df26cacSmrg *lpix++ = fg; 1746df26cacSmrg *lpix++ = fg; 1756df26cacSmrg *lpix++ = fg; 1766df26cacSmrg break; 1776df26cacSmrg case 8: 1786df26cacSmrg *lpix++ = fg; 1796df26cacSmrg *lpix++ = bg; 1806df26cacSmrg *lpix++ = bg; 1816df26cacSmrg *lpix++ = bg; 1826df26cacSmrg break; 1836df26cacSmrg case 9: 1846df26cacSmrg *lpix++ = fg; 1856df26cacSmrg *lpix++ = bg; 1866df26cacSmrg *lpix++ = bg; 1876df26cacSmrg *lpix++ = fg; 1886df26cacSmrg break; 1896df26cacSmrg case 10: 1906df26cacSmrg *lpix++ = fg; 1916df26cacSmrg *lpix++ = bg; 1926df26cacSmrg *lpix++ = fg; 1936df26cacSmrg *lpix++ = bg; 1946df26cacSmrg break; 1956df26cacSmrg case 11: 1966df26cacSmrg *lpix++ = fg; 1976df26cacSmrg *lpix++ = bg; 1986df26cacSmrg *lpix++ = fg; 1996df26cacSmrg *lpix++ = fg; 2006df26cacSmrg break; 2016df26cacSmrg case 12: 2026df26cacSmrg *lpix++ = fg; 2036df26cacSmrg *lpix++ = fg; 2046df26cacSmrg *lpix++ = bg; 2056df26cacSmrg *lpix++ = bg; 2066df26cacSmrg break; 2076df26cacSmrg case 13: 2086df26cacSmrg *lpix++ = fg; 2096df26cacSmrg *lpix++ = fg; 2106df26cacSmrg *lpix++ = bg; 2116df26cacSmrg *lpix++ = fg; 2126df26cacSmrg break; 2136df26cacSmrg case 14: 2146df26cacSmrg *lpix++ = fg; 2156df26cacSmrg *lpix++ = fg; 2166df26cacSmrg *lpix++ = fg; 2176df26cacSmrg *lpix++ = bg; 2186df26cacSmrg break; 2196df26cacSmrg case 15: 2206df26cacSmrg *lpix++ = fg; 2216df26cacSmrg *lpix++ = fg; 2226df26cacSmrg *lpix++ = fg; 2236df26cacSmrg *lpix++ = fg; 2246df26cacSmrg break; 2256df26cacSmrg } 2266df26cacSmrg 2276df26cacSmrg expbits = *lbits & 0x0f; 2286df26cacSmrg 2296df26cacSmrg j -= 4; 2306df26cacSmrg if (j < 4) { 2316df26cacSmrg break; 2326df26cacSmrg } 2336df26cacSmrg 2346df26cacSmrg switch (expbits) { 2356df26cacSmrg case 0: 2366df26cacSmrg *lpix++ = bg; 2376df26cacSmrg *lpix++ = bg; 2386df26cacSmrg *lpix++ = bg; 2396df26cacSmrg *lpix++ = bg; 2406df26cacSmrg break; 2416df26cacSmrg case 1: 2426df26cacSmrg *lpix++ = bg; 2436df26cacSmrg *lpix++ = bg; 2446df26cacSmrg *lpix++ = bg; 2456df26cacSmrg *lpix++ = fg; 2466df26cacSmrg break; 2476df26cacSmrg case 2: 2486df26cacSmrg *lpix++ = bg; 2496df26cacSmrg *lpix++ = bg; 2506df26cacSmrg *lpix++ = fg; 2516df26cacSmrg *lpix++ = bg; 2526df26cacSmrg break; 2536df26cacSmrg case 3: 2546df26cacSmrg *lpix++ = bg; 2556df26cacSmrg *lpix++ = bg; 2566df26cacSmrg *lpix++ = fg; 2576df26cacSmrg *lpix++ = fg; 2586df26cacSmrg break; 2596df26cacSmrg case 4: 2606df26cacSmrg *lpix++ = bg; 2616df26cacSmrg *lpix++ = fg; 2626df26cacSmrg *lpix++ = bg; 2636df26cacSmrg *lpix++ = bg; 2646df26cacSmrg break; 2656df26cacSmrg case 5: 2666df26cacSmrg *lpix++ = bg; 2676df26cacSmrg *lpix++ = fg; 2686df26cacSmrg *lpix++ = bg; 2696df26cacSmrg *lpix++ = fg; 2706df26cacSmrg break; 2716df26cacSmrg case 6: 2726df26cacSmrg *lpix++ = bg; 2736df26cacSmrg *lpix++ = fg; 2746df26cacSmrg *lpix++ = fg; 2756df26cacSmrg *lpix++ = bg; 2766df26cacSmrg break; 2776df26cacSmrg case 7: 2786df26cacSmrg *lpix++ = bg; 2796df26cacSmrg *lpix++ = fg; 2806df26cacSmrg *lpix++ = fg; 2816df26cacSmrg *lpix++ = fg; 2826df26cacSmrg break; 2836df26cacSmrg case 8: 2846df26cacSmrg *lpix++ = fg; 2856df26cacSmrg *lpix++ = bg; 2866df26cacSmrg *lpix++ = bg; 2876df26cacSmrg *lpix++ = bg; 2886df26cacSmrg break; 2896df26cacSmrg case 9: 2906df26cacSmrg *lpix++ = fg; 2916df26cacSmrg *lpix++ = bg; 2926df26cacSmrg *lpix++ = bg; 2936df26cacSmrg *lpix++ = fg; 2946df26cacSmrg break; 2956df26cacSmrg case 10: 2966df26cacSmrg *lpix++ = fg; 2976df26cacSmrg *lpix++ = bg; 2986df26cacSmrg *lpix++ = fg; 2996df26cacSmrg *lpix++ = bg; 3006df26cacSmrg break; 3016df26cacSmrg case 11: 3026df26cacSmrg *lpix++ = fg; 3036df26cacSmrg *lpix++ = bg; 3046df26cacSmrg *lpix++ = fg; 3056df26cacSmrg *lpix++ = fg; 3066df26cacSmrg break; 3076df26cacSmrg case 12: 3086df26cacSmrg *lpix++ = fg; 3096df26cacSmrg *lpix++ = fg; 3106df26cacSmrg *lpix++ = bg; 3116df26cacSmrg *lpix++ = bg; 3126df26cacSmrg break; 3136df26cacSmrg case 13: 3146df26cacSmrg *lpix++ = fg; 3156df26cacSmrg *lpix++ = fg; 3166df26cacSmrg *lpix++ = bg; 3176df26cacSmrg *lpix++ = fg; 3186df26cacSmrg break; 3196df26cacSmrg case 14: 3206df26cacSmrg *lpix++ = fg; 3216df26cacSmrg *lpix++ = fg; 3226df26cacSmrg *lpix++ = fg; 3236df26cacSmrg *lpix++ = bg; 3246df26cacSmrg break; 3256df26cacSmrg case 15: 3266df26cacSmrg *lpix++ = fg; 3276df26cacSmrg *lpix++ = fg; 3286df26cacSmrg *lpix++ = fg; 3296df26cacSmrg *lpix++ = fg; 3306df26cacSmrg break; 3316df26cacSmrg } 3326df26cacSmrg lbits++; 3336df26cacSmrg } 3346df26cacSmrg 3356df26cacSmrg if (j > 0) { 3366df26cacSmrg *lpix++ = (expbits & 0x08) ? fg : bg; 3376df26cacSmrg j--; 3386df26cacSmrg if (j > 0) { 3396df26cacSmrg *lpix++ = (expbits & 0x04) ? fg : bg; 3406df26cacSmrg j--; 3416df26cacSmrg if (j > 0) { 3426df26cacSmrg *lpix++ = (expbits & 0x02) ? fg : bg; 3436df26cacSmrg j--; 3446df26cacSmrg } 3456df26cacSmrg } 3466df26cacSmrg } 3476df26cacSmrg 3486df26cacSmrg pix += pix_increment; 3496df26cacSmrg bits += bits_increment; 3506df26cacSmrg } 3516df26cacSmrg return; 3526df26cacSmrg} 3536df26cacSmrg 3546df26cacSmrg 3556df26cacSmrg/* 3566df26cacSmrg *---------------------------------------------------------------------- 3576df26cacSmrg * 3586df26cacSmrg * RasterBitsToPixels16 -- 3596df26cacSmrg * 3606df26cacSmrg * Convert a bitmap to a pixmap, converting 1 bits to the foreground 3616df26cacSmrg * color (fg) and 0 bits to the background color (bg), for a 16-bit 3626df26cacSmrg * pixmap 3636df26cacSmrg * 3646df26cacSmrg * Results: 3656df26cacSmrg * Pixmap filled with pixels 3666df26cacSmrg * 3676df26cacSmrg * Side effects: 3686df26cacSmrg * None 3696df26cacSmrg * 3706df26cacSmrg *---------------------------------------------------------------------- 3716df26cacSmrg */ 3726df26cacSmrg 3736df26cacSmrgvoid 3746df26cacSmrgRasterBitsToPixels16(uint8 *bits, uint32 bits_increment, 3756df26cacSmrg uint8 *pix, uint32 pix_increment, 3766df26cacSmrg uint32 width, uint32 height, uint32 fg, uint32 bg) 3776df26cacSmrg{ 3786df26cacSmrg uint16 *lpix; 3796df26cacSmrg uint8 *lbits; 3806df26cacSmrg int i, j; 3816df26cacSmrg uint32 expbits = 0; /* Bits to be expanded */ 3826df26cacSmrg 3836df26cacSmrg for (i=0; i<height; i++) { 3846df26cacSmrg lpix = (uint16 *)pix; 3856df26cacSmrg lbits = bits; 3866df26cacSmrg for (j = width; j > 0; j -= 4) { 3876df26cacSmrg expbits = (*lbits >> 4) & 0x0f; 3886df26cacSmrg 3896df26cacSmrg if (j < 4) 3906df26cacSmrg break; 3916df26cacSmrg 3926df26cacSmrg switch (expbits) { 3936df26cacSmrg case 0: 3946df26cacSmrg *lpix++ = bg; 3956df26cacSmrg *lpix++ = bg; 3966df26cacSmrg *lpix++ = bg; 3976df26cacSmrg *lpix++ = bg; 3986df26cacSmrg break; 3996df26cacSmrg case 1: 4006df26cacSmrg *lpix++ = bg; 4016df26cacSmrg *lpix++ = bg; 4026df26cacSmrg *lpix++ = bg; 4036df26cacSmrg *lpix++ = fg; 4046df26cacSmrg break; 4056df26cacSmrg case 2: 4066df26cacSmrg *lpix++ = bg; 4076df26cacSmrg *lpix++ = bg; 4086df26cacSmrg *lpix++ = fg; 4096df26cacSmrg *lpix++ = bg; 4106df26cacSmrg break; 4116df26cacSmrg case 3: 4126df26cacSmrg *lpix++ = bg; 4136df26cacSmrg *lpix++ = bg; 4146df26cacSmrg *lpix++ = fg; 4156df26cacSmrg *lpix++ = fg; 4166df26cacSmrg break; 4176df26cacSmrg case 4: 4186df26cacSmrg *lpix++ = bg; 4196df26cacSmrg *lpix++ = fg; 4206df26cacSmrg *lpix++ = bg; 4216df26cacSmrg *lpix++ = bg; 4226df26cacSmrg break; 4236df26cacSmrg case 5: 4246df26cacSmrg *lpix++ = bg; 4256df26cacSmrg *lpix++ = fg; 4266df26cacSmrg *lpix++ = bg; 4276df26cacSmrg *lpix++ = fg; 4286df26cacSmrg break; 4296df26cacSmrg case 6: 4306df26cacSmrg *lpix++ = bg; 4316df26cacSmrg *lpix++ = fg; 4326df26cacSmrg *lpix++ = fg; 4336df26cacSmrg *lpix++ = bg; 4346df26cacSmrg break; 4356df26cacSmrg case 7: 4366df26cacSmrg *lpix++ = bg; 4376df26cacSmrg *lpix++ = fg; 4386df26cacSmrg *lpix++ = fg; 4396df26cacSmrg *lpix++ = fg; 4406df26cacSmrg break; 4416df26cacSmrg case 8: 4426df26cacSmrg *lpix++ = fg; 4436df26cacSmrg *lpix++ = bg; 4446df26cacSmrg *lpix++ = bg; 4456df26cacSmrg *lpix++ = bg; 4466df26cacSmrg break; 4476df26cacSmrg case 9: 4486df26cacSmrg *lpix++ = fg; 4496df26cacSmrg *lpix++ = bg; 4506df26cacSmrg *lpix++ = bg; 4516df26cacSmrg *lpix++ = fg; 4526df26cacSmrg break; 4536df26cacSmrg case 10: 4546df26cacSmrg *lpix++ = fg; 4556df26cacSmrg *lpix++ = bg; 4566df26cacSmrg *lpix++ = fg; 4576df26cacSmrg *lpix++ = bg; 4586df26cacSmrg break; 4596df26cacSmrg case 11: 4606df26cacSmrg *lpix++ = fg; 4616df26cacSmrg *lpix++ = bg; 4626df26cacSmrg *lpix++ = fg; 4636df26cacSmrg *lpix++ = fg; 4646df26cacSmrg break; 4656df26cacSmrg case 12: 4666df26cacSmrg *lpix++ = fg; 4676df26cacSmrg *lpix++ = fg; 4686df26cacSmrg *lpix++ = bg; 4696df26cacSmrg *lpix++ = bg; 4706df26cacSmrg break; 4716df26cacSmrg case 13: 4726df26cacSmrg *lpix++ = fg; 4736df26cacSmrg *lpix++ = fg; 4746df26cacSmrg *lpix++ = bg; 4756df26cacSmrg *lpix++ = fg; 4766df26cacSmrg break; 4776df26cacSmrg case 14: 4786df26cacSmrg *lpix++ = fg; 4796df26cacSmrg *lpix++ = fg; 4806df26cacSmrg *lpix++ = fg; 4816df26cacSmrg *lpix++ = bg; 4826df26cacSmrg break; 4836df26cacSmrg case 15: 4846df26cacSmrg *lpix++ = fg; 4856df26cacSmrg *lpix++ = fg; 4866df26cacSmrg *lpix++ = fg; 4876df26cacSmrg *lpix++ = fg; 4886df26cacSmrg break; 4896df26cacSmrg } 4906df26cacSmrg 4916df26cacSmrg expbits = *lbits & 0x0f; 4926df26cacSmrg 4936df26cacSmrg j -= 4; 4946df26cacSmrg if (j < 4) { 4956df26cacSmrg break; 4966df26cacSmrg } 4976df26cacSmrg 4986df26cacSmrg switch (expbits) { 4996df26cacSmrg case 0: 5006df26cacSmrg *lpix++ = bg; 5016df26cacSmrg *lpix++ = bg; 5026df26cacSmrg *lpix++ = bg; 5036df26cacSmrg *lpix++ = bg; 5046df26cacSmrg break; 5056df26cacSmrg case 1: 5066df26cacSmrg *lpix++ = bg; 5076df26cacSmrg *lpix++ = bg; 5086df26cacSmrg *lpix++ = bg; 5096df26cacSmrg *lpix++ = fg; 5106df26cacSmrg break; 5116df26cacSmrg case 2: 5126df26cacSmrg *lpix++ = bg; 5136df26cacSmrg *lpix++ = bg; 5146df26cacSmrg *lpix++ = fg; 5156df26cacSmrg *lpix++ = bg; 5166df26cacSmrg break; 5176df26cacSmrg case 3: 5186df26cacSmrg *lpix++ = bg; 5196df26cacSmrg *lpix++ = bg; 5206df26cacSmrg *lpix++ = fg; 5216df26cacSmrg *lpix++ = fg; 5226df26cacSmrg break; 5236df26cacSmrg case 4: 5246df26cacSmrg *lpix++ = bg; 5256df26cacSmrg *lpix++ = fg; 5266df26cacSmrg *lpix++ = bg; 5276df26cacSmrg *lpix++ = bg; 5286df26cacSmrg break; 5296df26cacSmrg case 5: 5306df26cacSmrg *lpix++ = bg; 5316df26cacSmrg *lpix++ = fg; 5326df26cacSmrg *lpix++ = bg; 5336df26cacSmrg *lpix++ = fg; 5346df26cacSmrg break; 5356df26cacSmrg case 6: 5366df26cacSmrg *lpix++ = bg; 5376df26cacSmrg *lpix++ = fg; 5386df26cacSmrg *lpix++ = fg; 5396df26cacSmrg *lpix++ = bg; 5406df26cacSmrg break; 5416df26cacSmrg case 7: 5426df26cacSmrg *lpix++ = bg; 5436df26cacSmrg *lpix++ = fg; 5446df26cacSmrg *lpix++ = fg; 5456df26cacSmrg *lpix++ = fg; 5466df26cacSmrg break; 5476df26cacSmrg case 8: 5486df26cacSmrg *lpix++ = fg; 5496df26cacSmrg *lpix++ = bg; 5506df26cacSmrg *lpix++ = bg; 5516df26cacSmrg *lpix++ = bg; 5526df26cacSmrg break; 5536df26cacSmrg case 9: 5546df26cacSmrg *lpix++ = fg; 5556df26cacSmrg *lpix++ = bg; 5566df26cacSmrg *lpix++ = bg; 5576df26cacSmrg *lpix++ = fg; 5586df26cacSmrg break; 5596df26cacSmrg case 10: 5606df26cacSmrg *lpix++ = fg; 5616df26cacSmrg *lpix++ = bg; 5626df26cacSmrg *lpix++ = fg; 5636df26cacSmrg *lpix++ = bg; 5646df26cacSmrg break; 5656df26cacSmrg case 11: 5666df26cacSmrg *lpix++ = fg; 5676df26cacSmrg *lpix++ = bg; 5686df26cacSmrg *lpix++ = fg; 5696df26cacSmrg *lpix++ = fg; 5706df26cacSmrg break; 5716df26cacSmrg case 12: 5726df26cacSmrg *lpix++ = fg; 5736df26cacSmrg *lpix++ = fg; 5746df26cacSmrg *lpix++ = bg; 5756df26cacSmrg *lpix++ = bg; 5766df26cacSmrg break; 5776df26cacSmrg case 13: 5786df26cacSmrg *lpix++ = fg; 5796df26cacSmrg *lpix++ = fg; 5806df26cacSmrg *lpix++ = bg; 5816df26cacSmrg *lpix++ = fg; 5826df26cacSmrg break; 5836df26cacSmrg case 14: 5846df26cacSmrg *lpix++ = fg; 5856df26cacSmrg *lpix++ = fg; 5866df26cacSmrg *lpix++ = fg; 5876df26cacSmrg *lpix++ = bg; 5886df26cacSmrg break; 5896df26cacSmrg case 15: 5906df26cacSmrg *lpix++ = fg; 5916df26cacSmrg *lpix++ = fg; 5926df26cacSmrg *lpix++ = fg; 5936df26cacSmrg *lpix++ = fg; 5946df26cacSmrg break; 5956df26cacSmrg } 5966df26cacSmrg lbits++; 5976df26cacSmrg } 5986df26cacSmrg 5996df26cacSmrg if (j > 0) { 6006df26cacSmrg *lpix++ = (expbits & 0x08) ? fg : bg; 6016df26cacSmrg j--; 6026df26cacSmrg if (j > 0) { 6036df26cacSmrg *lpix++ = (expbits & 0x04) ? fg : bg; 6046df26cacSmrg j--; 6056df26cacSmrg if (j > 0) { 6066df26cacSmrg *lpix++ = (expbits & 0x02) ? fg : bg; 6076df26cacSmrg j--; 6086df26cacSmrg } 6096df26cacSmrg } 6106df26cacSmrg } 6116df26cacSmrg 6126df26cacSmrg pix += pix_increment; 6136df26cacSmrg bits += bits_increment; 6146df26cacSmrg } 6156df26cacSmrg return; 6166df26cacSmrg} 6176df26cacSmrg 6186df26cacSmrg 6196df26cacSmrg 6206df26cacSmrg/* 6216df26cacSmrg *---------------------------------------------------------------------- 6226df26cacSmrg * 6236df26cacSmrg * RasterBitsToPixels24 -- 6246df26cacSmrg * 6256df26cacSmrg * Convert a bitmap to a pixmap, converting 1 bits to the foreground 6266df26cacSmrg * color (fg) and 0 bits to the background color (bg), for a 24-bit 6276df26cacSmrg * pixmap 6286df26cacSmrg * 6296df26cacSmrg * Results: 6306df26cacSmrg * Pixmap filled with pixels 6316df26cacSmrg * 6326df26cacSmrg * Side effects: 6336df26cacSmrg * None 6346df26cacSmrg * 6356df26cacSmrg *---------------------------------------------------------------------- 6366df26cacSmrg */ 6376df26cacSmrg 6386df26cacSmrgvoid 6396df26cacSmrgRasterBitsToPixels24(uint8 *bits, uint32 bits_increment, 6406df26cacSmrg uint8 *pix, uint32 pix_increment, 6416df26cacSmrg uint32 width, uint32 height, uint32 fg, uint32 bg) 6426df26cacSmrg{ 6436df26cacSmrg uint8 *lpix, *lbits; 6446df26cacSmrg uint32 fgColor1, fgColor2, fgColor3; 6456df26cacSmrg uint32 bgColor1, bgColor2, bgColor3; 6466df26cacSmrg 6476df26cacSmrg int i, j; 6486df26cacSmrg uint32 expbits = 0; /* Bits to be expanded */ 6496df26cacSmrg 6506df26cacSmrg fgColor1 = fg & 0x000000ff; 6516df26cacSmrg fgColor2 = (fg >> 8) & 0x000000ff; 6526df26cacSmrg fgColor3 = (fg >> 16) & 0x000000ff; 6536df26cacSmrg 6546df26cacSmrg bgColor1 = bg & 0x000000ff; 6556df26cacSmrg bgColor2 = (bg >> 8) & 0x000000ff; 6566df26cacSmrg bgColor3 = (bg >> 16) & 0x000000ff; 6576df26cacSmrg 6586df26cacSmrg for (i=0; i<height; i++) { 6596df26cacSmrg lpix = pix; 6606df26cacSmrg lbits = bits; 6616df26cacSmrg for (j = width; j > 0; j -= 4) { 6626df26cacSmrg expbits = (*lbits >> 4) & 0x0f; 6636df26cacSmrg 6646df26cacSmrg if (j < 4) 6656df26cacSmrg break; 6666df26cacSmrg 6676df26cacSmrg switch (expbits) { 6686df26cacSmrg case 0: 6696df26cacSmrg *lpix++ = bgColor1; 6706df26cacSmrg *lpix++ = bgColor2; 6716df26cacSmrg *lpix++ = bgColor3; 6726df26cacSmrg *lpix++ = bgColor1; 6736df26cacSmrg *lpix++ = bgColor2; 6746df26cacSmrg *lpix++ = bgColor3; 6756df26cacSmrg *lpix++ = bgColor1; 6766df26cacSmrg *lpix++ = bgColor2; 6776df26cacSmrg *lpix++ = bgColor3; 6786df26cacSmrg *lpix++ = bgColor1; 6796df26cacSmrg *lpix++ = bgColor2; 6806df26cacSmrg *lpix++ = bgColor3; 6816df26cacSmrg break; 6826df26cacSmrg case 1: 6836df26cacSmrg *lpix++ = bgColor1; 6846df26cacSmrg *lpix++ = bgColor2; 6856df26cacSmrg *lpix++ = bgColor3; 6866df26cacSmrg *lpix++ = bgColor1; 6876df26cacSmrg *lpix++ = bgColor2; 6886df26cacSmrg *lpix++ = bgColor3; 6896df26cacSmrg *lpix++ = bgColor1; 6906df26cacSmrg *lpix++ = bgColor2; 6916df26cacSmrg *lpix++ = bgColor3; 6926df26cacSmrg *lpix++ = fgColor1; 6936df26cacSmrg *lpix++ = fgColor2; 6946df26cacSmrg *lpix++ = fgColor3; 6956df26cacSmrg break; 6966df26cacSmrg case 2: 6976df26cacSmrg *lpix++ = bgColor1; 6986df26cacSmrg *lpix++ = bgColor2; 6996df26cacSmrg *lpix++ = bgColor3; 7006df26cacSmrg *lpix++ = bgColor1; 7016df26cacSmrg *lpix++ = bgColor2; 7026df26cacSmrg *lpix++ = bgColor3; 7036df26cacSmrg *lpix++ = fgColor1; 7046df26cacSmrg *lpix++ = fgColor2; 7056df26cacSmrg *lpix++ = fgColor3; 7066df26cacSmrg *lpix++ = bgColor1; 7076df26cacSmrg *lpix++ = bgColor2; 7086df26cacSmrg *lpix++ = bgColor3; 7096df26cacSmrg break; 7106df26cacSmrg case 3: 7116df26cacSmrg *lpix++ = bgColor1; 7126df26cacSmrg *lpix++ = bgColor2; 7136df26cacSmrg *lpix++ = bgColor3; 7146df26cacSmrg *lpix++ = bgColor1; 7156df26cacSmrg *lpix++ = bgColor2; 7166df26cacSmrg *lpix++ = bgColor3; 7176df26cacSmrg *lpix++ = fgColor1; 7186df26cacSmrg *lpix++ = fgColor2; 7196df26cacSmrg *lpix++ = fgColor3; 7206df26cacSmrg *lpix++ = fgColor1; 7216df26cacSmrg *lpix++ = fgColor2; 7226df26cacSmrg *lpix++ = fgColor3; 7236df26cacSmrg break; 7246df26cacSmrg case 4: 7256df26cacSmrg *lpix++ = bgColor1; 7266df26cacSmrg *lpix++ = bgColor2; 7276df26cacSmrg *lpix++ = bgColor3; 7286df26cacSmrg *lpix++ = fgColor1; 7296df26cacSmrg *lpix++ = fgColor2; 7306df26cacSmrg *lpix++ = fgColor3; 7316df26cacSmrg *lpix++ = bgColor1; 7326df26cacSmrg *lpix++ = bgColor2; 7336df26cacSmrg *lpix++ = bgColor3; 7346df26cacSmrg *lpix++ = bgColor1; 7356df26cacSmrg *lpix++ = bgColor2; 7366df26cacSmrg *lpix++ = bgColor3; 7376df26cacSmrg break; 7386df26cacSmrg case 5: 7396df26cacSmrg *lpix++ = bgColor1; 7406df26cacSmrg *lpix++ = bgColor2; 7416df26cacSmrg *lpix++ = bgColor3; 7426df26cacSmrg *lpix++ = fgColor1; 7436df26cacSmrg *lpix++ = fgColor2; 7446df26cacSmrg *lpix++ = fgColor3; 7456df26cacSmrg *lpix++ = bgColor1; 7466df26cacSmrg *lpix++ = bgColor2; 7476df26cacSmrg *lpix++ = bgColor3; 7486df26cacSmrg *lpix++ = fgColor1; 7496df26cacSmrg *lpix++ = fgColor2; 7506df26cacSmrg *lpix++ = fgColor3; 7516df26cacSmrg break; 7526df26cacSmrg case 6: 7536df26cacSmrg *lpix++ = bgColor1; 7546df26cacSmrg *lpix++ = bgColor2; 7556df26cacSmrg *lpix++ = bgColor3; 7566df26cacSmrg *lpix++ = fgColor1; 7576df26cacSmrg *lpix++ = fgColor2; 7586df26cacSmrg *lpix++ = fgColor3; 7596df26cacSmrg *lpix++ = fgColor1; 7606df26cacSmrg *lpix++ = fgColor2; 7616df26cacSmrg *lpix++ = fgColor3; 7626df26cacSmrg *lpix++ = bgColor1; 7636df26cacSmrg *lpix++ = bgColor2; 7646df26cacSmrg *lpix++ = bgColor3; 7656df26cacSmrg break; 7666df26cacSmrg case 7: 7676df26cacSmrg *lpix++ = bgColor1; 7686df26cacSmrg *lpix++ = bgColor2; 7696df26cacSmrg *lpix++ = bgColor3; 7706df26cacSmrg *lpix++ = fgColor1; 7716df26cacSmrg *lpix++ = fgColor2; 7726df26cacSmrg *lpix++ = fgColor3; 7736df26cacSmrg *lpix++ = fgColor1; 7746df26cacSmrg *lpix++ = fgColor2; 7756df26cacSmrg *lpix++ = fgColor3; 7766df26cacSmrg *lpix++ = fgColor1; 7776df26cacSmrg *lpix++ = fgColor2; 7786df26cacSmrg *lpix++ = fgColor3; 7796df26cacSmrg break; 7806df26cacSmrg case 8: 7816df26cacSmrg *lpix++ = fgColor1; 7826df26cacSmrg *lpix++ = fgColor2; 7836df26cacSmrg *lpix++ = fgColor3; 7846df26cacSmrg *lpix++ = bgColor1; 7856df26cacSmrg *lpix++ = bgColor2; 7866df26cacSmrg *lpix++ = bgColor3; 7876df26cacSmrg *lpix++ = bgColor1; 7886df26cacSmrg *lpix++ = bgColor2; 7896df26cacSmrg *lpix++ = bgColor3; 7906df26cacSmrg *lpix++ = bgColor1; 7916df26cacSmrg *lpix++ = bgColor2; 7926df26cacSmrg *lpix++ = bgColor3; 7936df26cacSmrg break; 7946df26cacSmrg case 9: 7956df26cacSmrg *lpix++ = fgColor1; 7966df26cacSmrg *lpix++ = fgColor2; 7976df26cacSmrg *lpix++ = fgColor3; 7986df26cacSmrg *lpix++ = bgColor1; 7996df26cacSmrg *lpix++ = bgColor2; 8006df26cacSmrg *lpix++ = bgColor3; 8016df26cacSmrg *lpix++ = bgColor1; 8026df26cacSmrg *lpix++ = bgColor2; 8036df26cacSmrg *lpix++ = bgColor3; 8046df26cacSmrg *lpix++ = fgColor1; 8056df26cacSmrg *lpix++ = fgColor2; 8066df26cacSmrg *lpix++ = fgColor3; 8076df26cacSmrg break; 8086df26cacSmrg case 10: 8096df26cacSmrg *lpix++ = fgColor1; 8106df26cacSmrg *lpix++ = fgColor2; 8116df26cacSmrg *lpix++ = fgColor3; 8126df26cacSmrg *lpix++ = bgColor1; 8136df26cacSmrg *lpix++ = bgColor2; 8146df26cacSmrg *lpix++ = bgColor3; 8156df26cacSmrg *lpix++ = fgColor1; 8166df26cacSmrg *lpix++ = fgColor2; 8176df26cacSmrg *lpix++ = fgColor3; 8186df26cacSmrg *lpix++ = bgColor1; 8196df26cacSmrg *lpix++ = bgColor2; 8206df26cacSmrg *lpix++ = bgColor3; 8216df26cacSmrg break; 8226df26cacSmrg case 11: 8236df26cacSmrg *lpix++ = fgColor1; 8246df26cacSmrg *lpix++ = fgColor2; 8256df26cacSmrg *lpix++ = fgColor3; 8266df26cacSmrg *lpix++ = bgColor1; 8276df26cacSmrg *lpix++ = bgColor2; 8286df26cacSmrg *lpix++ = bgColor3; 8296df26cacSmrg *lpix++ = fgColor1; 8306df26cacSmrg *lpix++ = fgColor2; 8316df26cacSmrg *lpix++ = fgColor3; 8326df26cacSmrg *lpix++ = fgColor1; 8336df26cacSmrg *lpix++ = fgColor2; 8346df26cacSmrg *lpix++ = fgColor3; 8356df26cacSmrg break; 8366df26cacSmrg case 12: 8376df26cacSmrg *lpix++ = fgColor1; 8386df26cacSmrg *lpix++ = fgColor2; 8396df26cacSmrg *lpix++ = fgColor3; 8406df26cacSmrg *lpix++ = fgColor1; 8416df26cacSmrg *lpix++ = fgColor2; 8426df26cacSmrg *lpix++ = fgColor3; 8436df26cacSmrg *lpix++ = bgColor1; 8446df26cacSmrg *lpix++ = bgColor2; 8456df26cacSmrg *lpix++ = bgColor3; 8466df26cacSmrg *lpix++ = bgColor1; 8476df26cacSmrg *lpix++ = bgColor2; 8486df26cacSmrg *lpix++ = bgColor3; 8496df26cacSmrg break; 8506df26cacSmrg case 13: 8516df26cacSmrg *lpix++ = fgColor1; 8526df26cacSmrg *lpix++ = fgColor2; 8536df26cacSmrg *lpix++ = fgColor3; 8546df26cacSmrg *lpix++ = fgColor1; 8556df26cacSmrg *lpix++ = fgColor2; 8566df26cacSmrg *lpix++ = fgColor3; 8576df26cacSmrg *lpix++ = bgColor1; 8586df26cacSmrg *lpix++ = bgColor2; 8596df26cacSmrg *lpix++ = bgColor3; 8606df26cacSmrg *lpix++ = fgColor1; 8616df26cacSmrg *lpix++ = fgColor2; 8626df26cacSmrg *lpix++ = fgColor3; 8636df26cacSmrg break; 8646df26cacSmrg case 14: 8656df26cacSmrg *lpix++ = fgColor1; 8666df26cacSmrg *lpix++ = fgColor2; 8676df26cacSmrg *lpix++ = fgColor3; 8686df26cacSmrg *lpix++ = fgColor1; 8696df26cacSmrg *lpix++ = fgColor2; 8706df26cacSmrg *lpix++ = fgColor3; 8716df26cacSmrg *lpix++ = fgColor1; 8726df26cacSmrg *lpix++ = fgColor2; 8736df26cacSmrg *lpix++ = fgColor3; 8746df26cacSmrg *lpix++ = bgColor1; 8756df26cacSmrg *lpix++ = bgColor2; 8766df26cacSmrg *lpix++ = bgColor3; 8776df26cacSmrg break; 8786df26cacSmrg case 15: 8796df26cacSmrg *lpix++ = fgColor1; 8806df26cacSmrg *lpix++ = fgColor2; 8816df26cacSmrg *lpix++ = fgColor3; 8826df26cacSmrg *lpix++ = fgColor1; 8836df26cacSmrg *lpix++ = fgColor2; 8846df26cacSmrg *lpix++ = fgColor3; 8856df26cacSmrg *lpix++ = fgColor1; 8866df26cacSmrg *lpix++ = fgColor2; 8876df26cacSmrg *lpix++ = fgColor3; 8886df26cacSmrg *lpix++ = fgColor1; 8896df26cacSmrg *lpix++ = fgColor2; 8906df26cacSmrg *lpix++ = fgColor3; 8916df26cacSmrg break; 8926df26cacSmrg } 8936df26cacSmrg 8946df26cacSmrg expbits = *lbits & 0x0f; 8956df26cacSmrg 8966df26cacSmrg j -= 4; 8976df26cacSmrg if (j < 4) { 8986df26cacSmrg break; 8996df26cacSmrg } 9006df26cacSmrg 9016df26cacSmrg switch (expbits) { 9026df26cacSmrg case 0: 9036df26cacSmrg *lpix++ = bgColor1; 9046df26cacSmrg *lpix++ = bgColor2; 9056df26cacSmrg *lpix++ = bgColor3; 9066df26cacSmrg *lpix++ = bgColor1; 9076df26cacSmrg *lpix++ = bgColor2; 9086df26cacSmrg *lpix++ = bgColor3; 9096df26cacSmrg *lpix++ = bgColor1; 9106df26cacSmrg *lpix++ = bgColor2; 9116df26cacSmrg *lpix++ = bgColor3; 9126df26cacSmrg *lpix++ = bgColor1; 9136df26cacSmrg *lpix++ = bgColor2; 9146df26cacSmrg *lpix++ = bgColor3; 9156df26cacSmrg break; 9166df26cacSmrg case 1: 9176df26cacSmrg *lpix++ = bgColor1; 9186df26cacSmrg *lpix++ = bgColor2; 9196df26cacSmrg *lpix++ = bgColor3; 9206df26cacSmrg *lpix++ = bgColor1; 9216df26cacSmrg *lpix++ = bgColor2; 9226df26cacSmrg *lpix++ = bgColor3; 9236df26cacSmrg *lpix++ = bgColor1; 9246df26cacSmrg *lpix++ = bgColor2; 9256df26cacSmrg *lpix++ = bgColor3; 9266df26cacSmrg *lpix++ = fgColor1; 9276df26cacSmrg *lpix++ = fgColor2; 9286df26cacSmrg *lpix++ = fgColor3; 9296df26cacSmrg break; 9306df26cacSmrg case 2: 9316df26cacSmrg *lpix++ = bgColor1; 9326df26cacSmrg *lpix++ = bgColor2; 9336df26cacSmrg *lpix++ = bgColor3; 9346df26cacSmrg *lpix++ = bgColor1; 9356df26cacSmrg *lpix++ = bgColor2; 9366df26cacSmrg *lpix++ = bgColor3; 9376df26cacSmrg *lpix++ = fgColor1; 9386df26cacSmrg *lpix++ = fgColor2; 9396df26cacSmrg *lpix++ = fgColor3; 9406df26cacSmrg *lpix++ = bgColor1; 9416df26cacSmrg *lpix++ = bgColor2; 9426df26cacSmrg *lpix++ = bgColor3; 9436df26cacSmrg break; 9446df26cacSmrg case 3: 9456df26cacSmrg *lpix++ = bgColor1; 9466df26cacSmrg *lpix++ = bgColor2; 9476df26cacSmrg *lpix++ = bgColor3; 9486df26cacSmrg *lpix++ = bgColor1; 9496df26cacSmrg *lpix++ = bgColor2; 9506df26cacSmrg *lpix++ = bgColor3; 9516df26cacSmrg *lpix++ = fgColor1; 9526df26cacSmrg *lpix++ = fgColor2; 9536df26cacSmrg *lpix++ = fgColor3; 9546df26cacSmrg *lpix++ = fgColor1; 9556df26cacSmrg *lpix++ = fgColor2; 9566df26cacSmrg *lpix++ = fgColor3; 9576df26cacSmrg break; 9586df26cacSmrg case 4: 9596df26cacSmrg *lpix++ = bgColor1; 9606df26cacSmrg *lpix++ = bgColor2; 9616df26cacSmrg *lpix++ = bgColor3; 9626df26cacSmrg *lpix++ = fgColor1; 9636df26cacSmrg *lpix++ = fgColor2; 9646df26cacSmrg *lpix++ = fgColor3; 9656df26cacSmrg *lpix++ = bgColor1; 9666df26cacSmrg *lpix++ = bgColor2; 9676df26cacSmrg *lpix++ = bgColor3; 9686df26cacSmrg *lpix++ = bgColor1; 9696df26cacSmrg *lpix++ = bgColor2; 9706df26cacSmrg *lpix++ = bgColor3; 9716df26cacSmrg break; 9726df26cacSmrg case 5: 9736df26cacSmrg *lpix++ = bgColor1; 9746df26cacSmrg *lpix++ = bgColor2; 9756df26cacSmrg *lpix++ = bgColor3; 9766df26cacSmrg *lpix++ = fgColor1; 9776df26cacSmrg *lpix++ = fgColor2; 9786df26cacSmrg *lpix++ = fgColor3; 9796df26cacSmrg *lpix++ = bgColor1; 9806df26cacSmrg *lpix++ = bgColor2; 9816df26cacSmrg *lpix++ = bgColor3; 9826df26cacSmrg *lpix++ = fgColor1; 9836df26cacSmrg *lpix++ = fgColor2; 9846df26cacSmrg *lpix++ = fgColor3; 9856df26cacSmrg break; 9866df26cacSmrg case 6: 9876df26cacSmrg *lpix++ = bgColor1; 9886df26cacSmrg *lpix++ = bgColor2; 9896df26cacSmrg *lpix++ = bgColor3; 9906df26cacSmrg *lpix++ = fgColor1; 9916df26cacSmrg *lpix++ = fgColor2; 9926df26cacSmrg *lpix++ = fgColor3; 9936df26cacSmrg *lpix++ = fgColor1; 9946df26cacSmrg *lpix++ = fgColor2; 9956df26cacSmrg *lpix++ = fgColor3; 9966df26cacSmrg *lpix++ = bgColor1; 9976df26cacSmrg *lpix++ = bgColor2; 9986df26cacSmrg *lpix++ = bgColor3; 9996df26cacSmrg break; 10006df26cacSmrg case 7: 10016df26cacSmrg *lpix++ = bgColor1; 10026df26cacSmrg *lpix++ = bgColor2; 10036df26cacSmrg *lpix++ = bgColor3; 10046df26cacSmrg *lpix++ = fgColor1; 10056df26cacSmrg *lpix++ = fgColor2; 10066df26cacSmrg *lpix++ = fgColor3; 10076df26cacSmrg *lpix++ = fgColor1; 10086df26cacSmrg *lpix++ = fgColor2; 10096df26cacSmrg *lpix++ = fgColor3; 10106df26cacSmrg *lpix++ = fgColor1; 10116df26cacSmrg *lpix++ = fgColor2; 10126df26cacSmrg *lpix++ = fgColor3; 10136df26cacSmrg break; 10146df26cacSmrg case 8: 10156df26cacSmrg *lpix++ = fgColor1; 10166df26cacSmrg *lpix++ = fgColor2; 10176df26cacSmrg *lpix++ = fgColor3; 10186df26cacSmrg *lpix++ = bgColor1; 10196df26cacSmrg *lpix++ = bgColor2; 10206df26cacSmrg *lpix++ = bgColor3; 10216df26cacSmrg *lpix++ = bgColor1; 10226df26cacSmrg *lpix++ = bgColor2; 10236df26cacSmrg *lpix++ = bgColor3; 10246df26cacSmrg *lpix++ = bgColor1; 10256df26cacSmrg *lpix++ = bgColor2; 10266df26cacSmrg *lpix++ = bgColor3; 10276df26cacSmrg break; 10286df26cacSmrg case 9: 10296df26cacSmrg *lpix++ = fgColor1; 10306df26cacSmrg *lpix++ = fgColor2; 10316df26cacSmrg *lpix++ = fgColor3; 10326df26cacSmrg *lpix++ = bgColor1; 10336df26cacSmrg *lpix++ = bgColor2; 10346df26cacSmrg *lpix++ = bgColor3; 10356df26cacSmrg *lpix++ = bgColor1; 10366df26cacSmrg *lpix++ = bgColor2; 10376df26cacSmrg *lpix++ = bgColor3; 10386df26cacSmrg *lpix++ = fgColor1; 10396df26cacSmrg *lpix++ = fgColor2; 10406df26cacSmrg *lpix++ = fgColor3; 10416df26cacSmrg break; 10426df26cacSmrg case 10: 10436df26cacSmrg *lpix++ = fgColor1; 10446df26cacSmrg *lpix++ = fgColor2; 10456df26cacSmrg *lpix++ = fgColor3; 10466df26cacSmrg *lpix++ = bgColor1; 10476df26cacSmrg *lpix++ = bgColor2; 10486df26cacSmrg *lpix++ = bgColor3; 10496df26cacSmrg *lpix++ = fgColor1; 10506df26cacSmrg *lpix++ = fgColor2; 10516df26cacSmrg *lpix++ = fgColor3; 10526df26cacSmrg *lpix++ = bgColor1; 10536df26cacSmrg *lpix++ = bgColor2; 10546df26cacSmrg *lpix++ = bgColor3; 10556df26cacSmrg break; 10566df26cacSmrg case 11: 10576df26cacSmrg *lpix++ = fgColor1; 10586df26cacSmrg *lpix++ = fgColor2; 10596df26cacSmrg *lpix++ = fgColor3; 10606df26cacSmrg *lpix++ = bgColor1; 10616df26cacSmrg *lpix++ = bgColor2; 10626df26cacSmrg *lpix++ = bgColor3; 10636df26cacSmrg *lpix++ = fgColor1; 10646df26cacSmrg *lpix++ = fgColor2; 10656df26cacSmrg *lpix++ = fgColor3; 10666df26cacSmrg *lpix++ = fgColor1; 10676df26cacSmrg *lpix++ = fgColor2; 10686df26cacSmrg *lpix++ = fgColor3; 10696df26cacSmrg break; 10706df26cacSmrg case 12: 10716df26cacSmrg *lpix++ = fgColor1; 10726df26cacSmrg *lpix++ = fgColor2; 10736df26cacSmrg *lpix++ = fgColor3; 10746df26cacSmrg *lpix++ = fgColor1; 10756df26cacSmrg *lpix++ = fgColor2; 10766df26cacSmrg *lpix++ = fgColor3; 10776df26cacSmrg *lpix++ = bgColor1; 10786df26cacSmrg *lpix++ = bgColor2; 10796df26cacSmrg *lpix++ = bgColor3; 10806df26cacSmrg *lpix++ = bgColor1; 10816df26cacSmrg *lpix++ = bgColor2; 10826df26cacSmrg *lpix++ = bgColor3; 10836df26cacSmrg break; 10846df26cacSmrg case 13: 10856df26cacSmrg *lpix++ = fgColor1; 10866df26cacSmrg *lpix++ = fgColor2; 10876df26cacSmrg *lpix++ = fgColor3; 10886df26cacSmrg *lpix++ = fgColor1; 10896df26cacSmrg *lpix++ = fgColor2; 10906df26cacSmrg *lpix++ = fgColor3; 10916df26cacSmrg *lpix++ = bgColor1; 10926df26cacSmrg *lpix++ = bgColor2; 10936df26cacSmrg *lpix++ = bgColor3; 10946df26cacSmrg *lpix++ = fgColor1; 10956df26cacSmrg *lpix++ = fgColor2; 10966df26cacSmrg *lpix++ = fgColor3; 10976df26cacSmrg break; 10986df26cacSmrg case 14: 10996df26cacSmrg *lpix++ = fgColor1; 11006df26cacSmrg *lpix++ = fgColor2; 11016df26cacSmrg *lpix++ = fgColor3; 11026df26cacSmrg *lpix++ = fgColor1; 11036df26cacSmrg *lpix++ = fgColor2; 11046df26cacSmrg *lpix++ = fgColor3; 11056df26cacSmrg *lpix++ = fgColor1; 11066df26cacSmrg *lpix++ = fgColor2; 11076df26cacSmrg *lpix++ = fgColor3; 11086df26cacSmrg *lpix++ = bgColor1; 11096df26cacSmrg *lpix++ = bgColor2; 11106df26cacSmrg *lpix++ = bgColor3; 11116df26cacSmrg break; 11126df26cacSmrg case 15: 11136df26cacSmrg *lpix++ = fgColor1; 11146df26cacSmrg *lpix++ = fgColor2; 11156df26cacSmrg *lpix++ = fgColor3; 11166df26cacSmrg *lpix++ = fgColor1; 11176df26cacSmrg *lpix++ = fgColor2; 11186df26cacSmrg *lpix++ = fgColor3; 11196df26cacSmrg *lpix++ = fgColor1; 11206df26cacSmrg *lpix++ = fgColor2; 11216df26cacSmrg *lpix++ = fgColor3; 11226df26cacSmrg *lpix++ = fgColor1; 11236df26cacSmrg *lpix++ = fgColor2; 11246df26cacSmrg *lpix++ = fgColor3; 11256df26cacSmrg break; 11266df26cacSmrg } 11276df26cacSmrg lbits++; 11286df26cacSmrg } 11296df26cacSmrg 11306df26cacSmrg if (j > 0) { 11316df26cacSmrg *lpix++ = (expbits & 0x08) ? fgColor1 : bgColor1; 11326df26cacSmrg *lpix++ = (expbits & 0x08) ? fgColor2 : bgColor2; 11336df26cacSmrg *lpix++ = (expbits & 0x08) ? fgColor3 : bgColor3; 11346df26cacSmrg j--; 11356df26cacSmrg if (j > 0) { 11366df26cacSmrg *lpix++ = (expbits & 0x04) ? fgColor1 : bgColor1; 11376df26cacSmrg *lpix++ = (expbits & 0x04) ? fgColor2 : bgColor2; 11386df26cacSmrg *lpix++ = (expbits & 0x04) ? fgColor3 : bgColor3; 11396df26cacSmrg j--; 11406df26cacSmrg if (j > 0) { 11416df26cacSmrg *lpix++ = (expbits & 0x02) ? fgColor1 : bgColor1; 11426df26cacSmrg *lpix++ = (expbits & 0x02) ? fgColor2 : bgColor2; 11436df26cacSmrg *lpix++ = (expbits & 0x02) ? fgColor3 : bgColor3; 11446df26cacSmrg j--; 11456df26cacSmrg } 11466df26cacSmrg } 11476df26cacSmrg } 11486df26cacSmrg 11496df26cacSmrg pix += pix_increment; 11506df26cacSmrg bits += bits_increment; 11516df26cacSmrg } 11526df26cacSmrg return; 11536df26cacSmrg} 11546df26cacSmrg 11556df26cacSmrg 11566df26cacSmrg 11576df26cacSmrg/* 11586df26cacSmrg *---------------------------------------------------------------------- 11596df26cacSmrg * 11606df26cacSmrg * RasterBitsToPixels32 -- 11616df26cacSmrg * 11626df26cacSmrg * Convert a bitmap to a pixmap, converting 1 bits to the foreground 11636df26cacSmrg * color (fg) and 0 bits to the background color (bg), for a 32-bit 11646df26cacSmrg * pixmap 11656df26cacSmrg * 11666df26cacSmrg * Results: 11676df26cacSmrg * Pixmap filled with pixels 11686df26cacSmrg * 11696df26cacSmrg * Side effects: 11706df26cacSmrg * None 11716df26cacSmrg * 11726df26cacSmrg *---------------------------------------------------------------------- 11736df26cacSmrg */ 11746df26cacSmrg 11756df26cacSmrgvoid 11766df26cacSmrgRasterBitsToPixels32(uint8 *bits, uint32 bits_increment, 11776df26cacSmrg uint8 *pix, uint32 pix_increment, 11786df26cacSmrg uint32 width, uint32 height, uint32 fg, uint32 bg) 11796df26cacSmrg{ 11806df26cacSmrg uint32 *lpix; 11816df26cacSmrg uint8 *lbits; 11826df26cacSmrg int i, j; 11836df26cacSmrg uint32 expbits = 0; /* Bits to be expanded */ 11846df26cacSmrg 11856df26cacSmrg for (i=0; i<height; i++) { 11866df26cacSmrg lpix = (uint32 *)pix; 11876df26cacSmrg lbits = bits; 11886df26cacSmrg for (j = width; j > 0; j -= 4) { 11896df26cacSmrg expbits = (*lbits >> 4) & 0x0f; 11906df26cacSmrg 11916df26cacSmrg if (j < 4) 11926df26cacSmrg break; 11936df26cacSmrg 11946df26cacSmrg switch (expbits) { 11956df26cacSmrg case 0: 11966df26cacSmrg *lpix++ = bg; 11976df26cacSmrg *lpix++ = bg; 11986df26cacSmrg *lpix++ = bg; 11996df26cacSmrg *lpix++ = bg; 12006df26cacSmrg break; 12016df26cacSmrg case 1: 12026df26cacSmrg *lpix++ = bg; 12036df26cacSmrg *lpix++ = bg; 12046df26cacSmrg *lpix++ = bg; 12056df26cacSmrg *lpix++ = fg; 12066df26cacSmrg break; 12076df26cacSmrg case 2: 12086df26cacSmrg *lpix++ = bg; 12096df26cacSmrg *lpix++ = bg; 12106df26cacSmrg *lpix++ = fg; 12116df26cacSmrg *lpix++ = bg; 12126df26cacSmrg break; 12136df26cacSmrg case 3: 12146df26cacSmrg *lpix++ = bg; 12156df26cacSmrg *lpix++ = bg; 12166df26cacSmrg *lpix++ = fg; 12176df26cacSmrg *lpix++ = fg; 12186df26cacSmrg break; 12196df26cacSmrg case 4: 12206df26cacSmrg *lpix++ = bg; 12216df26cacSmrg *lpix++ = fg; 12226df26cacSmrg *lpix++ = bg; 12236df26cacSmrg *lpix++ = bg; 12246df26cacSmrg break; 12256df26cacSmrg case 5: 12266df26cacSmrg *lpix++ = bg; 12276df26cacSmrg *lpix++ = fg; 12286df26cacSmrg *lpix++ = bg; 12296df26cacSmrg *lpix++ = fg; 12306df26cacSmrg break; 12316df26cacSmrg case 6: 12326df26cacSmrg *lpix++ = bg; 12336df26cacSmrg *lpix++ = fg; 12346df26cacSmrg *lpix++ = fg; 12356df26cacSmrg *lpix++ = bg; 12366df26cacSmrg break; 12376df26cacSmrg case 7: 12386df26cacSmrg *lpix++ = bg; 12396df26cacSmrg *lpix++ = fg; 12406df26cacSmrg *lpix++ = fg; 12416df26cacSmrg *lpix++ = fg; 12426df26cacSmrg break; 12436df26cacSmrg case 8: 12446df26cacSmrg *lpix++ = fg; 12456df26cacSmrg *lpix++ = bg; 12466df26cacSmrg *lpix++ = bg; 12476df26cacSmrg *lpix++ = bg; 12486df26cacSmrg break; 12496df26cacSmrg case 9: 12506df26cacSmrg *lpix++ = fg; 12516df26cacSmrg *lpix++ = bg; 12526df26cacSmrg *lpix++ = bg; 12536df26cacSmrg *lpix++ = fg; 12546df26cacSmrg break; 12556df26cacSmrg case 10: 12566df26cacSmrg *lpix++ = fg; 12576df26cacSmrg *lpix++ = bg; 12586df26cacSmrg *lpix++ = fg; 12596df26cacSmrg *lpix++ = bg; 12606df26cacSmrg break; 12616df26cacSmrg case 11: 12626df26cacSmrg *lpix++ = fg; 12636df26cacSmrg *lpix++ = bg; 12646df26cacSmrg *lpix++ = fg; 12656df26cacSmrg *lpix++ = fg; 12666df26cacSmrg break; 12676df26cacSmrg case 12: 12686df26cacSmrg *lpix++ = fg; 12696df26cacSmrg *lpix++ = fg; 12706df26cacSmrg *lpix++ = bg; 12716df26cacSmrg *lpix++ = bg; 12726df26cacSmrg break; 12736df26cacSmrg case 13: 12746df26cacSmrg *lpix++ = fg; 12756df26cacSmrg *lpix++ = fg; 12766df26cacSmrg *lpix++ = bg; 12776df26cacSmrg *lpix++ = fg; 12786df26cacSmrg break; 12796df26cacSmrg case 14: 12806df26cacSmrg *lpix++ = fg; 12816df26cacSmrg *lpix++ = fg; 12826df26cacSmrg *lpix++ = fg; 12836df26cacSmrg *lpix++ = bg; 12846df26cacSmrg break; 12856df26cacSmrg case 15: 12866df26cacSmrg *lpix++ = fg; 12876df26cacSmrg *lpix++ = fg; 12886df26cacSmrg *lpix++ = fg; 12896df26cacSmrg *lpix++ = fg; 12906df26cacSmrg break; 12916df26cacSmrg } 12926df26cacSmrg 12936df26cacSmrg expbits = *lbits & 0x0f; 12946df26cacSmrg 12956df26cacSmrg j -= 4; 12966df26cacSmrg if (j < 4) { 12976df26cacSmrg break; 12986df26cacSmrg } 12996df26cacSmrg 13006df26cacSmrg switch (expbits) { 13016df26cacSmrg case 0: 13026df26cacSmrg *lpix++ = bg; 13036df26cacSmrg *lpix++ = bg; 13046df26cacSmrg *lpix++ = bg; 13056df26cacSmrg *lpix++ = bg; 13066df26cacSmrg break; 13076df26cacSmrg case 1: 13086df26cacSmrg *lpix++ = bg; 13096df26cacSmrg *lpix++ = bg; 13106df26cacSmrg *lpix++ = bg; 13116df26cacSmrg *lpix++ = fg; 13126df26cacSmrg break; 13136df26cacSmrg case 2: 13146df26cacSmrg *lpix++ = bg; 13156df26cacSmrg *lpix++ = bg; 13166df26cacSmrg *lpix++ = fg; 13176df26cacSmrg *lpix++ = bg; 13186df26cacSmrg break; 13196df26cacSmrg case 3: 13206df26cacSmrg *lpix++ = bg; 13216df26cacSmrg *lpix++ = bg; 13226df26cacSmrg *lpix++ = fg; 13236df26cacSmrg *lpix++ = fg; 13246df26cacSmrg break; 13256df26cacSmrg case 4: 13266df26cacSmrg *lpix++ = bg; 13276df26cacSmrg *lpix++ = fg; 13286df26cacSmrg *lpix++ = bg; 13296df26cacSmrg *lpix++ = bg; 13306df26cacSmrg break; 13316df26cacSmrg case 5: 13326df26cacSmrg *lpix++ = bg; 13336df26cacSmrg *lpix++ = fg; 13346df26cacSmrg *lpix++ = bg; 13356df26cacSmrg *lpix++ = fg; 13366df26cacSmrg break; 13376df26cacSmrg case 6: 13386df26cacSmrg *lpix++ = bg; 13396df26cacSmrg *lpix++ = fg; 13406df26cacSmrg *lpix++ = fg; 13416df26cacSmrg *lpix++ = bg; 13426df26cacSmrg break; 13436df26cacSmrg case 7: 13446df26cacSmrg *lpix++ = bg; 13456df26cacSmrg *lpix++ = fg; 13466df26cacSmrg *lpix++ = fg; 13476df26cacSmrg *lpix++ = fg; 13486df26cacSmrg break; 13496df26cacSmrg case 8: 13506df26cacSmrg *lpix++ = fg; 13516df26cacSmrg *lpix++ = bg; 13526df26cacSmrg *lpix++ = bg; 13536df26cacSmrg *lpix++ = bg; 13546df26cacSmrg break; 13556df26cacSmrg case 9: 13566df26cacSmrg *lpix++ = fg; 13576df26cacSmrg *lpix++ = bg; 13586df26cacSmrg *lpix++ = bg; 13596df26cacSmrg *lpix++ = fg; 13606df26cacSmrg break; 13616df26cacSmrg case 10: 13626df26cacSmrg *lpix++ = fg; 13636df26cacSmrg *lpix++ = bg; 13646df26cacSmrg *lpix++ = fg; 13656df26cacSmrg *lpix++ = bg; 13666df26cacSmrg break; 13676df26cacSmrg case 11: 13686df26cacSmrg *lpix++ = fg; 13696df26cacSmrg *lpix++ = bg; 13706df26cacSmrg *lpix++ = fg; 13716df26cacSmrg *lpix++ = fg; 13726df26cacSmrg break; 13736df26cacSmrg case 12: 13746df26cacSmrg *lpix++ = fg; 13756df26cacSmrg *lpix++ = fg; 13766df26cacSmrg *lpix++ = bg; 13776df26cacSmrg *lpix++ = bg; 13786df26cacSmrg break; 13796df26cacSmrg case 13: 13806df26cacSmrg *lpix++ = fg; 13816df26cacSmrg *lpix++ = fg; 13826df26cacSmrg *lpix++ = bg; 13836df26cacSmrg *lpix++ = fg; 13846df26cacSmrg break; 13856df26cacSmrg case 14: 13866df26cacSmrg *lpix++ = fg; 13876df26cacSmrg *lpix++ = fg; 13886df26cacSmrg *lpix++ = fg; 13896df26cacSmrg *lpix++ = bg; 13906df26cacSmrg break; 13916df26cacSmrg case 15: 13926df26cacSmrg *lpix++ = fg; 13936df26cacSmrg *lpix++ = fg; 13946df26cacSmrg *lpix++ = fg; 13956df26cacSmrg *lpix++ = fg; 13966df26cacSmrg break; 13976df26cacSmrg } 13986df26cacSmrg lbits++; 13996df26cacSmrg } 14006df26cacSmrg 14016df26cacSmrg if (j > 0) { 14026df26cacSmrg *lpix++ = (expbits & 0x08) ? fg : bg; 14036df26cacSmrg j--; 14046df26cacSmrg if (j > 0) { 14056df26cacSmrg *lpix++ = (expbits & 0x04) ? fg : bg; 14066df26cacSmrg j--; 14076df26cacSmrg if (j > 0) { 14086df26cacSmrg *lpix++ = (expbits & 0x02) ? fg : bg; 14096df26cacSmrg j--; 14106df26cacSmrg } 14116df26cacSmrg } 14126df26cacSmrg } 14136df26cacSmrg 14146df26cacSmrg pix += pix_increment; 14156df26cacSmrg bits += bits_increment; 14166df26cacSmrg } 14176df26cacSmrg return; 14186df26cacSmrg} 1419