| 1 | #ifndef _INCLUDED_BITMAP_BIT2_BYTE |
|---|
| 2 | #define _INCLUDED_BITMAP_BIT2_BYTE |
|---|
| 3 | |
|---|
| 4 | UT_STATIC_API void Bit2ByteImage_0(unsigned char* image) |
|---|
| 5 | { |
|---|
| 6 | } |
|---|
| 7 | |
|---|
| 8 | UT_STATIC_API void Bit2ByteImage_1(unsigned char* image) |
|---|
| 9 | { |
|---|
| 10 | image[3] = 64; |
|---|
| 11 | } |
|---|
| 12 | |
|---|
| 13 | UT_STATIC_API void Bit2ByteImage_2(unsigned char* image) |
|---|
| 14 | { |
|---|
| 15 | image[2] = 64; |
|---|
| 16 | } |
|---|
| 17 | |
|---|
| 18 | UT_STATIC_API void Bit2ByteImage_3(unsigned char* image) |
|---|
| 19 | { |
|---|
| 20 | image[2] = 64; |
|---|
| 21 | image[3] = 64; |
|---|
| 22 | } |
|---|
| 23 | |
|---|
| 24 | UT_STATIC_API void Bit2ByteImage_4(unsigned char* image) |
|---|
| 25 | { |
|---|
| 26 | image[1] = 64; |
|---|
| 27 | } |
|---|
| 28 | |
|---|
| 29 | UT_STATIC_API void Bit2ByteImage_5(unsigned char* image) |
|---|
| 30 | { |
|---|
| 31 | image[1] = 64; |
|---|
| 32 | image[3] = 64; |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | UT_STATIC_API void Bit2ByteImage_6(unsigned char* image) |
|---|
| 36 | { |
|---|
| 37 | image[1] = 64; |
|---|
| 38 | image[2] = 64; |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | UT_STATIC_API void Bit2ByteImage_7(unsigned char* image) |
|---|
| 42 | { |
|---|
| 43 | image[1] = 64; |
|---|
| 44 | image[2] = 64; |
|---|
| 45 | image[3] = 64; |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | UT_STATIC_API void Bit2ByteImage_8(unsigned char* image) |
|---|
| 49 | { |
|---|
| 50 | image[0] = 64; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | UT_STATIC_API void Bit2ByteImage_9(unsigned char* image) |
|---|
| 54 | { |
|---|
| 55 | image[0] = 64; |
|---|
| 56 | image[3] = 64; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | UT_STATIC_API void Bit2ByteImage_10(unsigned char* image) |
|---|
| 60 | { |
|---|
| 61 | image[0] = 64; |
|---|
| 62 | image[2] = 64; |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | UT_STATIC_API void Bit2ByteImage_11(unsigned char* image) |
|---|
| 66 | { |
|---|
| 67 | image[0] = 64; |
|---|
| 68 | image[2] = 64; |
|---|
| 69 | image[3] = 64; |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | UT_STATIC_API void Bit2ByteImage_12(unsigned char* image) |
|---|
| 73 | { |
|---|
| 74 | image[0] = 64; |
|---|
| 75 | image[1] = 64; |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | UT_STATIC_API void Bit2ByteImage_13(unsigned char* image) |
|---|
| 79 | { |
|---|
| 80 | image[0] = 64; |
|---|
| 81 | image[1] = 64; |
|---|
| 82 | image[3] = 64; |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | UT_STATIC_API void Bit2ByteImage_14(unsigned char* image) |
|---|
| 86 | { |
|---|
| 87 | image[0] = 64; |
|---|
| 88 | image[1] = 64; |
|---|
| 89 | image[2] = 64; |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | UT_STATIC_API void Bit2ByteImage_15(unsigned char* image) |
|---|
| 93 | { |
|---|
| 94 | image[0] = 64; |
|---|
| 95 | image[1] = 64; |
|---|
| 96 | image[2] = 64; |
|---|
| 97 | image[3] = 64; |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | #ifdef _UT_NO_DATA_SEGMENT |
|---|
| 101 | #define ut_Bit2ByteImageFnt fontManager->Bit2ByteImageFnt |
|---|
| 102 | #define SET_VALUE(index, value) ut_Bit2ByteImageFnt[index] = value |
|---|
| 103 | UT_STATIC_API void ut_InitBit2ByteImageFnt(UT_FONT_MANAGER* fontManager) |
|---|
| 104 | { |
|---|
| 105 | #else |
|---|
| 106 | #define SET_VALUE(index, value) value |
|---|
| 107 | UT_STATIC_API void ut_InitBit2ByteImageFnt(UT_FONT_MANAGER* fontManager) {} |
|---|
| 108 | static void (*ut_Bit2ByteImageFnt[])(unsigned char* image) = |
|---|
| 109 | { |
|---|
| 110 | #endif |
|---|
| 111 | SET_VALUE( 0, Bit2ByteImage_0), |
|---|
| 112 | SET_VALUE( 1, Bit2ByteImage_1), |
|---|
| 113 | SET_VALUE( 2, Bit2ByteImage_2), |
|---|
| 114 | SET_VALUE( 3, Bit2ByteImage_3), |
|---|
| 115 | SET_VALUE( 4, Bit2ByteImage_4), |
|---|
| 116 | SET_VALUE( 5, Bit2ByteImage_5), |
|---|
| 117 | SET_VALUE( 6, Bit2ByteImage_6), |
|---|
| 118 | SET_VALUE( 7, Bit2ByteImage_7), |
|---|
| 119 | SET_VALUE( 8, Bit2ByteImage_8), |
|---|
| 120 | SET_VALUE( 9, Bit2ByteImage_9), |
|---|
| 121 | SET_VALUE(10, Bit2ByteImage_10), |
|---|
| 122 | SET_VALUE(11, Bit2ByteImage_11), |
|---|
| 123 | SET_VALUE(12, Bit2ByteImage_12), |
|---|
| 124 | SET_VALUE(13, Bit2ByteImage_13), |
|---|
| 125 | SET_VALUE(14, Bit2ByteImage_14), |
|---|
| 126 | SET_VALUE(15, Bit2ByteImage_15) |
|---|
| 127 | #ifdef _UT_NO_DATA_SEGMENT |
|---|
| 128 | ;} |
|---|
| 129 | #else |
|---|
| 130 | }; |
|---|
| 131 | #endif |
|---|
| 132 | #undef SET_VALUE |
|---|
| 133 | |
|---|
| 134 | /***************************************************************************/ |
|---|
| 135 | |
|---|
| 136 | void ut_Bit2ByteImage(UT_FONT_MANAGER* fontManager, |
|---|
| 137 | unsigned char* bit_image, int bit_bSize, |
|---|
| 138 | unsigned char* byte_image, int byte_bSize, |
|---|
| 139 | int xSize, int ySize, int ox, int oy) |
|---|
| 140 | { |
|---|
| 141 | int x, y; |
|---|
| 142 | unsigned char *ss, *dd; |
|---|
| 143 | int bSize = ut_BSIZE8(xSize); |
|---|
| 144 | byte_image += byte_bSize*oy + ox; |
|---|
| 145 | for (y=0; y<ySize; y++) |
|---|
| 146 | { |
|---|
| 147 | ss = bit_image; |
|---|
| 148 | dd = byte_image; |
|---|
| 149 | for (x=0; x<bSize; x++,ss++) |
|---|
| 150 | { |
|---|
| 151 | ut_Bit2ByteImageFnt[*ss>>4](dd); dd += 4; |
|---|
| 152 | ut_Bit2ByteImageFnt[*ss&15](dd); dd += 4; |
|---|
| 153 | } |
|---|
| 154 | bit_image += bit_bSize; |
|---|
| 155 | byte_image += byte_bSize; |
|---|
| 156 | } |
|---|
| 157 | } |
|---|
| 158 | |
|---|
| 159 | void ut_Bit2ByteImageP(UT_FONT_MANAGER* fontManager, |
|---|
| 160 | unsigned char* bit_image, |
|---|
| 161 | unsigned char* byte_image, int byte_bSize, |
|---|
| 162 | int xSize, int ySize, int ox, int oy) |
|---|
| 163 | { |
|---|
| 164 | int y, sx, stop; |
|---|
| 165 | // int s_bSize = ut_BSIZE8(xSize); |
|---|
| 166 | unsigned char* p; |
|---|
| 167 | unsigned char b; |
|---|
| 168 | unsigned short w = 0; |
|---|
| 169 | unsigned short f = 0; |
|---|
| 170 | byte_image += byte_bSize*oy + ox; |
|---|
| 171 | for (y=ySize; y; y--) |
|---|
| 172 | { |
|---|
| 173 | p = byte_image; |
|---|
| 174 | sx = xSize; |
|---|
| 175 | stop = 8; |
|---|
| 176 | while (sx > 0) |
|---|
| 177 | { |
|---|
| 178 | if (f < 8) |
|---|
| 179 | { |
|---|
| 180 | w <<= 8; |
|---|
| 181 | w |= *bit_image++; |
|---|
| 182 | f += 8; |
|---|
| 183 | } |
|---|
| 184 | if (stop > sx) stop = sx; |
|---|
| 185 | b = (w>>(f-8)) & 0xff & (~(0xff>>stop)); |
|---|
| 186 | ut_Bit2ByteImageFnt[b>>4](p); p += 4; |
|---|
| 187 | ut_Bit2ByteImageFnt[b&15](p); p += 4; |
|---|
| 188 | f -= stop; |
|---|
| 189 | sx -= stop; |
|---|
| 190 | } |
|---|
| 191 | byte_image += byte_bSize; |
|---|
| 192 | } |
|---|
| 193 | } |
|---|
| 194 | |
|---|
| 195 | #endif /*#ifndef _INCLUDED_BITMAP_BIT2_BYTE*/ |
|---|