| 1 | #ifndef _INCLUDED_BITMAP_EFFECT |
|---|
| 2 | #define _INCLUDED_BITMAP_EFFECT |
|---|
| 3 | |
|---|
| 4 | if (task->emulOutline) |
|---|
| 5 | { |
|---|
| 6 | d = image->data; |
|---|
| 7 | s = image->data; |
|---|
| 8 | if (task->emulOutline < 0) |
|---|
| 9 | { |
|---|
| 10 | for (y=0; y<i_ySize; y++) |
|---|
| 11 | { |
|---|
| 12 | for (x=0; x<i_xSize; x++) |
|---|
| 13 | { |
|---|
| 14 | if (!s[x]) continue; |
|---|
| 15 | else if (!s[x-1]) s[x] = 255; |
|---|
| 16 | else if (!s[x+1]) s[x] = 255; |
|---|
| 17 | else if (!s[x-d_bSize]) s[x] = 255; |
|---|
| 18 | else if (!s[x+d_bSize]) s[x] = 255; |
|---|
| 19 | } |
|---|
| 20 | s += d_bSize; |
|---|
| 21 | } |
|---|
| 22 | } |
|---|
| 23 | else if (task->emulOutline == _UT_EDGE_TYPE_OUTLINE) |
|---|
| 24 | { |
|---|
| 25 | for (y=0; y<i_ySize; y++) |
|---|
| 26 | { |
|---|
| 27 | for (x=0; x<i_xSize; x++) |
|---|
| 28 | { |
|---|
| 29 | if (!s[x]) continue; |
|---|
| 30 | if (s[x] == 255) continue; |
|---|
| 31 | if (!s[x-1]) s[x-1] = 255; |
|---|
| 32 | if (!s[x+1]) s[x+1] = 255; |
|---|
| 33 | if (!s[x-d_bSize]) s[x-d_bSize] = 255; |
|---|
| 34 | if (!s[x+d_bSize]) s[x+d_bSize] = 255; |
|---|
| 35 | } |
|---|
| 36 | s += d_bSize; |
|---|
| 37 | } |
|---|
| 38 | } |
|---|
| 39 | else /*if (task->emulOutline == _UT_EDGE_TYPE_OUTLINE1)*/ |
|---|
| 40 | { |
|---|
| 41 | for (y=0; y<i_ySize; y++) |
|---|
| 42 | { |
|---|
| 43 | for (x=0; x<i_xSize; x++) |
|---|
| 44 | { |
|---|
| 45 | if (!s[x]) continue; |
|---|
| 46 | if (s[x] == 255) continue; |
|---|
| 47 | if (!s[x-1]) s[x-1] = 255; |
|---|
| 48 | if (!s[x+1]) s[x+1] = 255; |
|---|
| 49 | if (!s[x-d_bSize]) s[x-d_bSize] = 255; |
|---|
| 50 | if (!s[x+d_bSize]) s[x+d_bSize] = 255; |
|---|
| 51 | if (!s[x-d_bSize-1]) s[x-d_bSize-1] = 255; |
|---|
| 52 | if (!s[x-d_bSize+1]) s[x-d_bSize+1] = 255; |
|---|
| 53 | if (!s[x+d_bSize-1]) s[x+d_bSize-1] = 255; |
|---|
| 54 | if (!s[x+d_bSize+1]) s[x+d_bSize+1] = 255; |
|---|
| 55 | } |
|---|
| 56 | s += d_bSize; |
|---|
| 57 | } |
|---|
| 58 | } |
|---|
| 59 | for (y=0; y<image->lSize; y++) |
|---|
| 60 | { |
|---|
| 61 | if (d[y] != 255) d[y] = 0; |
|---|
| 62 | } |
|---|
| 63 | for (y=0; y<image->lSize; y++) |
|---|
| 64 | { |
|---|
| 65 | if (d[y] == 255) d[y] = 64; |
|---|
| 66 | } |
|---|
| 67 | task->emulOutline = 0; |
|---|
| 68 | image->width += ut_GetExtraSizeEdge(task->ySize); |
|---|
| 69 | image->xAdvance += ut_GetExtraSizeEdge(task->ySize); |
|---|
| 70 | } |
|---|
| 71 | else if (task->emulEdge) |
|---|
| 72 | { |
|---|
| 73 | int i, j; |
|---|
| 74 | switch (task->emulEdge) |
|---|
| 75 | { |
|---|
| 76 | case _UT_EDGE_TYPE_SHADOW_RIGHT_TOP: /* Left-Top Shodow */ |
|---|
| 77 | { |
|---|
| 78 | d = image->data + image->lSize; |
|---|
| 79 | d += ut_GetExtraSizeEdge(task->ySize)*image->bSize; |
|---|
| 80 | d += ut_GetExtraSizeEdge(task->ySize); |
|---|
| 81 | s = image->data + image->lSize; |
|---|
| 82 | for (y=i_ySize-1; y>=0; y--) |
|---|
| 83 | { |
|---|
| 84 | d -= d_bSize; |
|---|
| 85 | s -= d_bSize; |
|---|
| 86 | for (x=0; x<i_xSize; x++) |
|---|
| 87 | { |
|---|
| 88 | if (!s[x] || d[x]) continue; |
|---|
| 89 | d[x] = _UT_IMAGE_TYPE_BITMAP_65_SHADOW_COLOR; |
|---|
| 90 | } |
|---|
| 91 | } |
|---|
| 92 | break; |
|---|
| 93 | } |
|---|
| 94 | case _UT_EDGE_TYPE_SHADOW_LEFT_TOP: /* Left-Top Shodow */ |
|---|
| 95 | { |
|---|
| 96 | d = image->data + image->lSize; |
|---|
| 97 | d += ut_GetExtraSizeEdge(task->ySize)*image->bSize; |
|---|
| 98 | d -= ut_GetExtraSizeEdge(task->ySize); |
|---|
| 99 | s = image->data + image->lSize; |
|---|
| 100 | for (y=i_ySize-1; y>=0; y--) |
|---|
| 101 | { |
|---|
| 102 | d -= d_bSize; |
|---|
| 103 | s -= d_bSize; |
|---|
| 104 | for (x=0; x<i_xSize; x++) |
|---|
| 105 | { |
|---|
| 106 | if (!s[x] || d[x]) continue; |
|---|
| 107 | d[x] = _UT_IMAGE_TYPE_BITMAP_65_SHADOW_COLOR; |
|---|
| 108 | } |
|---|
| 109 | } |
|---|
| 110 | break; |
|---|
| 111 | } |
|---|
| 112 | case _UT_EDGE_TYPE_RAISED: /* Left-Top Shodow */ |
|---|
| 113 | { |
|---|
| 114 | for (i=ut_GetExtraSizeEdge(task->ySize); i > 0; i --) |
|---|
| 115 | { |
|---|
| 116 | d = image->data + image->lSize; |
|---|
| 117 | #if 0 |
|---|
| 118 | d += ut_GetExtraSizeEdge(task->ySize)*image->bSize; |
|---|
| 119 | d -= ut_GetExtraSizeEdge(task->ySize); |
|---|
| 120 | #else |
|---|
| 121 | d += i*image->bSize; |
|---|
| 122 | d -= i; |
|---|
| 123 | #endif |
|---|
| 124 | s = image->data + image->lSize; |
|---|
| 125 | for (y=i_ySize-1; y>=0; y--) |
|---|
| 126 | { |
|---|
| 127 | d -= d_bSize; |
|---|
| 128 | s -= d_bSize; |
|---|
| 129 | for (x=0; x<i_xSize; x++) |
|---|
| 130 | { |
|---|
| 131 | if (!s[x] || d[x] || (s[x] == _UT_IMAGE_TYPE_BITMAP_65_SHADOW_COLOR)) continue; |
|---|
| 132 | d[x] = _UT_IMAGE_TYPE_BITMAP_65_SHADOW_COLOR; |
|---|
| 133 | } |
|---|
| 134 | } |
|---|
| 135 | } |
|---|
| 136 | break; |
|---|
| 137 | } |
|---|
| 138 | case _UT_EDGE_TYPE_DEPRESSED: /* Right-Bottom Shodow */ |
|---|
| 139 | { |
|---|
| 140 | for (i = ut_GetExtraSizeEdge(task->ySize); i > 0; i --) |
|---|
| 141 | { |
|---|
| 142 | d = image->data; |
|---|
| 143 | #if 0 |
|---|
| 144 | d -= ut_GetExtraSizeEdge(task->ySize)*image->bSize; |
|---|
| 145 | d += ut_GetExtraSizeEdge(task->ySize); |
|---|
| 146 | #else |
|---|
| 147 | d -= i*image->bSize; |
|---|
| 148 | d += i; |
|---|
| 149 | #endif |
|---|
| 150 | s = image->data; |
|---|
| 151 | for (y=i_ySize-1; y>=0; y--) |
|---|
| 152 | { |
|---|
| 153 | for (x=i_xSize-1; x>=0; x--) |
|---|
| 154 | { |
|---|
| 155 | if (!s[x] || d[x] || (s[x] == _UT_IMAGE_TYPE_BITMAP_65_SHADOW_COLOR)) continue; |
|---|
| 156 | d[x] = _UT_IMAGE_TYPE_BITMAP_65_SHADOW_COLOR; |
|---|
| 157 | } |
|---|
| 158 | d += d_bSize; |
|---|
| 159 | s += d_bSize; |
|---|
| 160 | } |
|---|
| 161 | } |
|---|
| 162 | break; |
|---|
| 163 | } |
|---|
| 164 | case _UT_EDGE_TYPE_UNIFORM: /* Border Shodow */ |
|---|
| 165 | { |
|---|
| 166 | d = image->data; |
|---|
| 167 | s = image->data; |
|---|
| 168 | for (y=0; y<i_ySize; y++) |
|---|
| 169 | { |
|---|
| 170 | for (x=0; x<i_xSize; x++) |
|---|
| 171 | { |
|---|
| 172 | if (!s[x]) continue; |
|---|
| 173 | if (s[x] == 255) continue; |
|---|
| 174 | if (!s[x-1]) s[x-1] = 255; |
|---|
| 175 | if (!s[x+1]) s[x+1] = 255; |
|---|
| 176 | if (!s[x-d_bSize]) s[x-d_bSize] = 255; |
|---|
| 177 | if (!s[x+d_bSize]) s[x+d_bSize] = 255; |
|---|
| 178 | } |
|---|
| 179 | s += d_bSize; |
|---|
| 180 | } |
|---|
| 181 | for (y=0; y<image->lSize; y++) |
|---|
| 182 | { |
|---|
| 183 | if (d[y] == 255) d[y] = _UT_IMAGE_TYPE_BITMAP_65_SHADOW_COLOR; |
|---|
| 184 | } |
|---|
| 185 | break; |
|---|
| 186 | } |
|---|
| 187 | case _UT_EDGE_TYPE_UNIFORM1: /* Border Shodow */ |
|---|
| 188 | { |
|---|
| 189 | d = image->data; |
|---|
| 190 | s = image->data; |
|---|
| 191 | for (y=0; y<i_ySize; y++) |
|---|
| 192 | { |
|---|
| 193 | for (x=0; x<i_xSize; x++) |
|---|
| 194 | { |
|---|
| 195 | if (!s[x]) continue; |
|---|
| 196 | if (s[x] == 255) continue; |
|---|
| 197 | if (!s[x-1]) s[x-1] = 255; |
|---|
| 198 | if (!s[x+1]) s[x+1] = 255; |
|---|
| 199 | if (!s[x-d_bSize]) s[x-d_bSize] = 255; |
|---|
| 200 | if (!s[x+d_bSize]) s[x+d_bSize] = 255; |
|---|
| 201 | if (!s[x-d_bSize-1]) s[x-d_bSize-1] = 255; |
|---|
| 202 | if (!s[x-d_bSize+1]) s[x-d_bSize+1] = 255; |
|---|
| 203 | if (!s[x+d_bSize-1]) s[x+d_bSize-1] = 255; |
|---|
| 204 | if (!s[x+d_bSize+1]) s[x+d_bSize+1] = 255; |
|---|
| 205 | } |
|---|
| 206 | s += d_bSize; |
|---|
| 207 | } |
|---|
| 208 | for (y=0; y<image->lSize; y++) |
|---|
| 209 | { |
|---|
| 210 | if (d[y] == 255) d[y] = _UT_IMAGE_TYPE_BITMAP_65_SHADOW_COLOR; |
|---|
| 211 | } |
|---|
| 212 | break; |
|---|
| 213 | } |
|---|
| 214 | case _UT_EDGE_TYPE_DROP_SHADOW: /* Reverse Left-Top Shodow */ |
|---|
| 215 | { |
|---|
| 216 | d = image->data + image->lSize; |
|---|
| 217 | d += ut_GetExtraSizeEdge(task->ySize)*image->bSize; |
|---|
| 218 | d -= ut_GetExtraSizeEdge(task->ySize); |
|---|
| 219 | s = image->data + image->lSize; |
|---|
| 220 | for (y=i_ySize-1; y>=0; y--) |
|---|
| 221 | { |
|---|
| 222 | d -= d_bSize; |
|---|
| 223 | s -= d_bSize; |
|---|
| 224 | for (x=0; x<i_xSize; x++) |
|---|
| 225 | { |
|---|
| 226 | if (s[x] != _UT_IMAGE_TYPE_BITMAP_65_COLOR) continue; |
|---|
| 227 | d[x] = _UT_IMAGE_TYPE_BITMAP_65_SHADOW_COLOR; |
|---|
| 228 | } |
|---|
| 229 | } |
|---|
| 230 | break; |
|---|
| 231 | } |
|---|
| 232 | case _UT_EDGE_TYPE_SHADOW_RIGHT_BOTTOM: /* Reverse Left-Top Shodow */ |
|---|
| 233 | { |
|---|
| 234 | d = image->data; |
|---|
| 235 | d -= ut_GetExtraSizeEdge(task->ySize)*image->bSize; |
|---|
| 236 | d += ut_GetExtraSizeEdge(task->ySize); |
|---|
| 237 | s = image->data; |
|---|
| 238 | for (y=i_ySize-1; y>=0; y--) |
|---|
| 239 | { |
|---|
| 240 | for (x=0; x<i_xSize; x++) |
|---|
| 241 | { |
|---|
| 242 | if (!s[x] || d[x]) continue; |
|---|
| 243 | d[x] = _UT_IMAGE_TYPE_BITMAP_65_SHADOW_COLOR; |
|---|
| 244 | } |
|---|
| 245 | d += d_bSize; |
|---|
| 246 | s += d_bSize; |
|---|
| 247 | } |
|---|
| 248 | break; |
|---|
| 249 | } |
|---|
| 250 | case _UT_EDGE_TYPE_SHADOW_LEFT_BOTTOM: /* Reverse Left-Top Shodow */ |
|---|
| 251 | { |
|---|
| 252 | d = image->data; |
|---|
| 253 | d -= ut_GetExtraSizeEdge(task->ySize)*image->bSize; |
|---|
| 254 | d -= ut_GetExtraSizeEdge(task->ySize); |
|---|
| 255 | s = image->data; |
|---|
| 256 | for (y=i_ySize-1; y>=0; y--) |
|---|
| 257 | { |
|---|
| 258 | for (x=0; x<i_xSize; x++) |
|---|
| 259 | { |
|---|
| 260 | if (!s[x] || d[x]) continue; |
|---|
| 261 | d[x] = _UT_IMAGE_TYPE_BITMAP_65_SHADOW_COLOR; |
|---|
| 262 | } |
|---|
| 263 | d += d_bSize; |
|---|
| 264 | s += d_bSize; |
|---|
| 265 | } |
|---|
| 266 | break; |
|---|
| 267 | } |
|---|
| 268 | case _UT_EDGE_TYPE_EMBOSS: /* Left-Top White */ |
|---|
| 269 | { |
|---|
| 270 | d = image->data + image->lSize; |
|---|
| 271 | d += ut_GetExtraSizeEdge(task->ySize)*image->bSize; |
|---|
| 272 | d -= ut_GetExtraSizeEdge(task->ySize); |
|---|
| 273 | s = image->data + image->lSize; |
|---|
| 274 | for (y=i_ySize-1; y>=0; y--) |
|---|
| 275 | { |
|---|
| 276 | d -= d_bSize; |
|---|
| 277 | s -= d_bSize; |
|---|
| 278 | for (x=0; x<i_xSize; x++) |
|---|
| 279 | { |
|---|
| 280 | if (!s[x]) continue; |
|---|
| 281 | d[x] = 0; |
|---|
| 282 | } |
|---|
| 283 | } |
|---|
| 284 | break; |
|---|
| 285 | } |
|---|
| 286 | case _UT_EDGE_TYPE_ENGRAVE: /* Right-Bottom White */ |
|---|
| 287 | { |
|---|
| 288 | d = image->data; |
|---|
| 289 | d -= ut_GetExtraSizeEdge(task->ySize)*image->bSize; |
|---|
| 290 | d += ut_GetExtraSizeEdge(task->ySize); |
|---|
| 291 | s = image->data; |
|---|
| 292 | for (y=i_ySize-1; y>=0; y--) |
|---|
| 293 | { |
|---|
| 294 | for (x=i_xSize-1; x>=0; x--) |
|---|
| 295 | { |
|---|
| 296 | if (!s[x]) continue; |
|---|
| 297 | d[x] = 0; |
|---|
| 298 | } |
|---|
| 299 | d += d_bSize; |
|---|
| 300 | s += d_bSize; |
|---|
| 301 | } |
|---|
| 302 | break; |
|---|
| 303 | } |
|---|
| 304 | /*-----------------------------------*/ |
|---|
| 305 | case _UT_EDGE_TYPE_BLUR: |
|---|
| 306 | /*-----------------------------------*/ |
|---|
| 307 | { |
|---|
| 308 | unsigned char blur, delta; |
|---|
| 309 | d = image->data; |
|---|
| 310 | s = image->data; |
|---|
| 311 | if (ut_GetExtraSizeEdge(task->ySize) < 2) |
|---|
| 312 | { |
|---|
| 313 | delta = 0x80; |
|---|
| 314 | for (y=0; y<image->lSize; y++) |
|---|
| 315 | if (d[y]) d[y] = d[y] + 0x80; |
|---|
| 316 | } |
|---|
| 317 | else |
|---|
| 318 | { |
|---|
| 319 | delta = 0x50; |
|---|
| 320 | for (y=0; y<image->lSize; y++) |
|---|
| 321 | if (d[y]) d[y] = d[y] / 4 + 0x80; |
|---|
| 322 | } |
|---|
| 323 | for (y=0; y<i_ySize; y++) |
|---|
| 324 | { |
|---|
| 325 | for (x=0; x<i_xSize; x++) |
|---|
| 326 | { |
|---|
| 327 | if (s[x] > 0x80) |
|---|
| 328 | { |
|---|
| 329 | for (i = 1; i <= ut_GetExtraSizeEdge(task->ySize); i ++) |
|---|
| 330 | { |
|---|
| 331 | blur = ut_GetBlurDelta(task->ySize, i); |
|---|
| 332 | if ((s[x-i] < 0x80)) s[x-i] += blur; |
|---|
| 333 | if ((s[x+i] < 0x80)) s[x+i] += blur; |
|---|
| 334 | if ((s[x-d_bSize*i] < 0x80)) s[x-d_bSize*i] += blur; |
|---|
| 335 | if ((s[x+d_bSize*i] < 0x80)) s[x+d_bSize*i] += blur; |
|---|
| 336 | for (j = 1; j <= i; j ++) |
|---|
| 337 | { |
|---|
| 338 | if ((s[x-d_bSize*i - j] < 0x80)) s[x-d_bSize*i - j] += blur; |
|---|
| 339 | if ((s[x-d_bSize*i + j] < 0x80)) s[x-d_bSize*i + j] += blur; |
|---|
| 340 | if ((s[x+d_bSize*i - j] < 0x80)) s[x+d_bSize*i - j] += blur; |
|---|
| 341 | if ((s[x+d_bSize*i + j] < 0x80)) s[x+d_bSize*i + j] += blur; |
|---|
| 342 | if ((s[x-d_bSize*j - i] < 0x80)) s[x-d_bSize*j - i] += blur; |
|---|
| 343 | if ((s[x+d_bSize*j - i] < 0x80)) s[x+d_bSize*j - i] += blur; |
|---|
| 344 | if ((s[x-d_bSize*j + i] < 0x80)) s[x-d_bSize*j + i] += blur; |
|---|
| 345 | if ((s[x+d_bSize*j + i] < 0x80)) s[x+d_bSize*j + i] += blur; |
|---|
| 346 | } |
|---|
| 347 | } |
|---|
| 348 | } |
|---|
| 349 | } |
|---|
| 350 | s += d_bSize; |
|---|
| 351 | } |
|---|
| 352 | for (y=0; y<image->lSize; y++) |
|---|
| 353 | { |
|---|
| 354 | if (d[y] >= 0x80) |
|---|
| 355 | d[y] -= delta; |
|---|
| 356 | } |
|---|
| 357 | break; |
|---|
| 358 | } |
|---|
| 359 | /*-----------------------------------*/ |
|---|
| 360 | case _UT_EDGE_TYPE_BORDER: |
|---|
| 361 | /*-----------------------------------*/ |
|---|
| 362 | #define FILL_BLOCK(index, offset, tval, val) do { \ |
|---|
| 363 | if ((s[x-index] == tval)) s[x-index] = val; \ |
|---|
| 364 | if ((s[x+index] == tval)) s[x+index] = val; \ |
|---|
| 365 | if ((s[x-d_bSize*index] == tval)) s[x-d_bSize*index] = val; \ |
|---|
| 366 | if ((s[x+d_bSize*index] == tval)) s[x+d_bSize*index] = val; \ |
|---|
| 367 | for (offset = 1; offset <= index; offset ++) \ |
|---|
| 368 | { \ |
|---|
| 369 | if ((s[x-d_bSize*index - offset] == tval)) s[x-d_bSize*index - offset] = val; \ |
|---|
| 370 | if ((s[x-d_bSize*index + offset] == tval)) s[x-d_bSize*index + offset] = val; \ |
|---|
| 371 | if ((s[x+d_bSize*index - offset] == tval)) s[x+d_bSize*index - offset] = val; \ |
|---|
| 372 | if ((s[x+d_bSize*index + offset] == tval)) s[x+d_bSize*index + offset] = val; \ |
|---|
| 373 | if ((s[x-d_bSize*offset - index] == tval)) s[x-d_bSize*offset - index] = val; \ |
|---|
| 374 | if ((s[x+d_bSize*offset - index] == tval)) s[x+d_bSize*offset - index] = val; \ |
|---|
| 375 | if ((s[x-d_bSize*offset + index] == tval)) s[x-d_bSize*offset + index] = val; \ |
|---|
| 376 | if ((s[x+d_bSize*offset + index] == tval)) s[x+d_bSize*offset + index] = val; \ |
|---|
| 377 | } \ |
|---|
| 378 | } while (0) |
|---|
| 379 | |
|---|
| 380 | { |
|---|
| 381 | int delta; |
|---|
| 382 | d = image->data; |
|---|
| 383 | s = image->data; |
|---|
| 384 | for (y=0; y<i_ySize; y++) |
|---|
| 385 | { |
|---|
| 386 | for (x=0; x<i_xSize; x++) |
|---|
| 387 | { |
|---|
| 388 | if (!s[x]) continue; |
|---|
| 389 | if (s[x] == 0xff) continue; |
|---|
| 390 | FILL_BLOCK(ut_GetExtraSizeEdge(task->ySize) * 2, j, 0, 0xff); |
|---|
| 391 | } |
|---|
| 392 | s += d_bSize; |
|---|
| 393 | } |
|---|
| 394 | d = image->data; |
|---|
| 395 | s = image->data; |
|---|
| 396 | delta = ut_GetExtraSizeEdge(task->ySize) * 2 - ut_GetBORDERDelta(task->ySize); |
|---|
| 397 | for (y=0; y<i_ySize; y++) |
|---|
| 398 | { |
|---|
| 399 | for (x=0; x<i_xSize; x++) |
|---|
| 400 | { |
|---|
| 401 | if (!s[x]) continue; |
|---|
| 402 | if (s[x] == 0xff) continue; |
|---|
| 403 | for (i = 1; i < delta; i ++) |
|---|
| 404 | FILL_BLOCK(i, j, 0xff, 0); |
|---|
| 405 | } |
|---|
| 406 | s += d_bSize; |
|---|
| 407 | } |
|---|
| 408 | for (y=0; y<image->lSize; y++) |
|---|
| 409 | { |
|---|
| 410 | if (d[y] == 0xff) |
|---|
| 411 | d[y] = _UT_IMAGE_TYPE_BITMAP_65_COLOR; |
|---|
| 412 | } |
|---|
| 413 | image->width += ut_GetExtraSizeEdge(task->ySize)*2; |
|---|
| 414 | image->xAdvance += ut_GetExtraSizeEdge(task->ySize)*2; |
|---|
| 415 | break; |
|---|
| 416 | } |
|---|
| 417 | } |
|---|
| 418 | task->emulEdge = 0; |
|---|
| 419 | image->width += ut_GetExtraSizeEdge(task->ySize); |
|---|
| 420 | image->xAdvance += ut_GetExtraSizeEdge(task->ySize); |
|---|
| 421 | } |
|---|
| 422 | if (task->emulSmooth && !task->emulEdge) |
|---|
| 423 | { |
|---|
| 424 | i_xSize--; |
|---|
| 425 | i_ySize--; |
|---|
| 426 | if (task->emulSmooth == _UT_SMOOTH_TYPE_GRAY) |
|---|
| 427 | { |
|---|
| 428 | s = image->data + d_bSize; |
|---|
| 429 | for (y=1; y<i_ySize; y++) |
|---|
| 430 | { |
|---|
| 431 | for (x=1; x<i_xSize; x++) |
|---|
| 432 | { |
|---|
| 433 | if (s[x] != _UT_IMAGE_TYPE_BITMAP_65_BACKGROUND_COLOR) |
|---|
| 434 | continue; |
|---|
| 435 | if ((s[x-1] == _UT_IMAGE_TYPE_BITMAP_65_COLOR) && |
|---|
| 436 | (s[x-d_bSize] == _UT_IMAGE_TYPE_BITMAP_65_COLOR)) |
|---|
| 437 | s[x] = _UT_IMAGE_TYPE_BITMAP_65_SMOOTH_COLOR_CORNER; |
|---|
| 438 | else if ((s[x-1] == _UT_IMAGE_TYPE_BITMAP_65_COLOR) && |
|---|
| 439 | (s[x+d_bSize] == _UT_IMAGE_TYPE_BITMAP_65_COLOR)) |
|---|
| 440 | s[x] = _UT_IMAGE_TYPE_BITMAP_65_SMOOTH_COLOR_CORNER; |
|---|
| 441 | if ((s[x+1] == _UT_IMAGE_TYPE_BITMAP_65_COLOR) && |
|---|
| 442 | (s[x-d_bSize] == _UT_IMAGE_TYPE_BITMAP_65_COLOR)) |
|---|
| 443 | s[x] = _UT_IMAGE_TYPE_BITMAP_65_SMOOTH_COLOR_CORNER; |
|---|
| 444 | else if ((s[x+1] == _UT_IMAGE_TYPE_BITMAP_65_COLOR) && |
|---|
| 445 | (s[x+d_bSize] == _UT_IMAGE_TYPE_BITMAP_65_COLOR)) |
|---|
| 446 | s[x] = _UT_IMAGE_TYPE_BITMAP_65_SMOOTH_COLOR_CORNER; |
|---|
| 447 | } |
|---|
| 448 | s += d_bSize; |
|---|
| 449 | } |
|---|
| 450 | s = image->data + d_bSize; |
|---|
| 451 | for (y=1; y<i_ySize; y++) |
|---|
| 452 | { |
|---|
| 453 | for (x=1; x<i_xSize; x++) |
|---|
| 454 | { |
|---|
| 455 | if (s[x] != _UT_IMAGE_TYPE_BITMAP_65_COLOR) |
|---|
| 456 | continue; |
|---|
| 457 | if (s[x-1] == _UT_IMAGE_TYPE_BITMAP_65_BACKGROUND_COLOR) |
|---|
| 458 | s[x-1] = _UT_IMAGE_TYPE_BITMAP_65_SMOOTH_COLOR_EDGE; |
|---|
| 459 | if (s[x+1] == _UT_IMAGE_TYPE_BITMAP_65_BACKGROUND_COLOR) |
|---|
| 460 | s[x+1] = _UT_IMAGE_TYPE_BITMAP_65_SMOOTH_COLOR_EDGE; |
|---|
| 461 | } |
|---|
| 462 | s += d_bSize; |
|---|
| 463 | } |
|---|
| 464 | } |
|---|
| 465 | else if (task->emulSmooth == _UT_SMOOTH_TYPE_SUBPIXEL_H) |
|---|
| 466 | { |
|---|
| 467 | i_xSize--; |
|---|
| 468 | i_ySize--; |
|---|
| 469 | d = image->data; |
|---|
| 470 | s = image->data + d_bSize + d_bSize; |
|---|
| 471 | for (y=2; y<i_ySize; y++) |
|---|
| 472 | { |
|---|
| 473 | for (x=2; x<i_xSize; x++) |
|---|
| 474 | { |
|---|
| 475 | unsigned char* ss = s + x; |
|---|
| 476 | unsigned char* p1 = ss + d_bSize; |
|---|
| 477 | unsigned char* p2 = p1 + d_bSize; |
|---|
| 478 | unsigned char* n1 = ss - d_bSize; |
|---|
| 479 | unsigned char* n2 = n1 - d_bSize; |
|---|
| 480 | if (*ss) continue; |
|---|
| 481 | if ((ss[+1] == 64) && (p1[0] == 64)) |
|---|
| 482 | { |
|---|
| 483 | if ((ss[-2] == 0) && (p1[-2] == 64) && |
|---|
| 484 | (ss[-1] == 0) && (p1[-1] == 64) && (n1[0] == 0) && (n1[+1] == 0)) |
|---|
| 485 | { |
|---|
| 486 | ss[0] = 251; |
|---|
| 487 | ss[-1] = 252; |
|---|
| 488 | } |
|---|
| 489 | else if ((n2[0] == 0) && (n2[+1] == 64) && |
|---|
| 490 | (n1[0] == 0) && (n1[+1] == 64) && (ss[-1] == 0) && (p1[-1] == 0)) |
|---|
| 491 | { |
|---|
| 492 | ss[0] = 251; |
|---|
| 493 | n1[0] = 252; |
|---|
| 494 | } |
|---|
| 495 | else |
|---|
| 496 | { |
|---|
| 497 | ss[0] = 253; |
|---|
| 498 | } |
|---|
| 499 | } |
|---|
| 500 | else if ((ss[+1] == 64) && (n1[0] == 64)) |
|---|
| 501 | { |
|---|
| 502 | if ((ss[-2] == 0) && (n1[-2] == 64) && |
|---|
| 503 | (ss[-1] == 0) && (n1[-1] == 64) && (p1[0] == 0) && (p1[+1] == 0)) |
|---|
| 504 | { |
|---|
| 505 | ss[0] = 251; |
|---|
| 506 | ss[-1] = 252; |
|---|
| 507 | } |
|---|
| 508 | else if ((p2[0] == 0) && (p2[+1] == 64) && |
|---|
| 509 | (p1[0] == 0) && (p1[+1] == 64) && (ss[-1] == 0) && (n1[-1] == 0)) |
|---|
| 510 | { |
|---|
| 511 | n1[0] = 251; |
|---|
| 512 | ss[0] = 252; |
|---|
| 513 | } |
|---|
| 514 | else |
|---|
| 515 | { |
|---|
| 516 | ss[0] = 253; |
|---|
| 517 | } |
|---|
| 518 | } |
|---|
| 519 | else if ((ss[-1] == 64) && (p1[0] == 64)) |
|---|
| 520 | { |
|---|
| 521 | if ((ss[+2] == 0) && (p1[+2] == 64) && |
|---|
| 522 | (ss[+1] == 0) && (p1[+1] == 64) && (n1[0] == 0) && (n1[-1] == 0)) |
|---|
| 523 | { |
|---|
| 524 | ss[0] = 251; |
|---|
| 525 | ss[+1] = 252; |
|---|
| 526 | } |
|---|
| 527 | else if ((n2[0] == 0) && (n2[-1] == 64) && |
|---|
| 528 | (n1[0] == 0) && (n1[-1] == 64) && (ss[+1] == 0) && (p1[+1] == 0)) |
|---|
| 529 | { |
|---|
| 530 | ss[0] = 251; |
|---|
| 531 | n1[0] = 252; |
|---|
| 532 | } |
|---|
| 533 | else |
|---|
| 534 | { |
|---|
| 535 | ss[0] = 253; |
|---|
| 536 | } |
|---|
| 537 | } |
|---|
| 538 | else if ((ss[-1] == 64) && (n1[0] == 64)) |
|---|
| 539 | { |
|---|
| 540 | if ((ss[+2] == 0) && (n1[+2] == 64) && |
|---|
| 541 | (ss[+1] == 0) && (n1[+1] == 64) && (p1[0] == 0) && (p1[-1] == 0)) |
|---|
| 542 | { |
|---|
| 543 | ss[0] = 251; |
|---|
| 544 | ss[+1] = 252; |
|---|
| 545 | } |
|---|
| 546 | else if ((p2[0] == 0) && (p2[-1] == 64) && |
|---|
| 547 | (p1[0] == 0) && (p1[-1] == 64) && (ss[+1] == 0) && (n1[+1] == 0)) |
|---|
| 548 | { |
|---|
| 549 | n1[0] = 251; |
|---|
| 550 | ss[0] = 252; |
|---|
| 551 | } |
|---|
| 552 | else |
|---|
| 553 | { |
|---|
| 554 | ss[0] = 253; |
|---|
| 555 | } |
|---|
| 556 | } |
|---|
| 557 | } |
|---|
| 558 | s += d_bSize; |
|---|
| 559 | } |
|---|
| 560 | for (y=image->lSize-1; y>=0; y--) |
|---|
| 561 | { |
|---|
| 562 | if (d[y] == 251) d[y] = _UT_IMAGE_TYPE_BITMAP_65_SMOOTH_COLOR_CORNER; |
|---|
| 563 | else if (d[y] == 252) d[y] = _UT_IMAGE_TYPE_BITMAP_65_SMOOTH_COLOR_EDGE; |
|---|
| 564 | else if (d[y] == 253) d[y] = _UT_IMAGE_TYPE_BITMAP_65_SMOOTH_COLOR_EDGE; |
|---|
| 565 | } |
|---|
| 566 | i_xSize++; |
|---|
| 567 | i_ySize++; |
|---|
| 568 | } |
|---|
| 569 | else if (task->emulSmooth == 3) |
|---|
| 570 | { |
|---|
| 571 | d = image->data; |
|---|
| 572 | s = image->data; |
|---|
| 573 | for (y=0; y<i_ySize; y++) |
|---|
| 574 | { |
|---|
| 575 | for (x=0; x<i_xSize; x++) |
|---|
| 576 | { |
|---|
| 577 | if (!s[x]) continue; |
|---|
| 578 | if (s[x] == 255) continue; |
|---|
| 579 | if (!s[x-1]) s[x-1] = 255; |
|---|
| 580 | if (!s[x+1]) s[x+1] = 255; |
|---|
| 581 | if (!s[x-d_bSize]) s[x-d_bSize] = 255; |
|---|
| 582 | if (!s[x+d_bSize]) s[x+d_bSize] = 255; |
|---|
| 583 | } |
|---|
| 584 | s += d_bSize; |
|---|
| 585 | } |
|---|
| 586 | for (y=0; y<image->lSize; y++) |
|---|
| 587 | { |
|---|
| 588 | if (d[y] == 255) d[y] = _UT_IMAGE_TYPE_BITMAP_65_SMOOTH_COLOR_CORNER; |
|---|
| 589 | } |
|---|
| 590 | d = image->data; |
|---|
| 591 | s = image->data; |
|---|
| 592 | for (y=0; y<i_ySize; y++) |
|---|
| 593 | { |
|---|
| 594 | for (x=0; x<i_xSize; x++) |
|---|
| 595 | { |
|---|
| 596 | if (!s[x]) continue; |
|---|
| 597 | if (s[x] == 255) continue; |
|---|
| 598 | if (!s[x-1]) s[x-1] = 255; |
|---|
| 599 | if (!s[x+1]) s[x+1] = 255; |
|---|
| 600 | if (!s[x-d_bSize]) s[x-d_bSize] = 255; |
|---|
| 601 | if (!s[x+d_bSize]) s[x+d_bSize] = 255; |
|---|
| 602 | } |
|---|
| 603 | s += d_bSize; |
|---|
| 604 | } |
|---|
| 605 | for (y=0; y<image->lSize; y++) |
|---|
| 606 | { |
|---|
| 607 | if (d[y] == 255) d[y] = _UT_IMAGE_TYPE_BITMAP_65_SMOOTH_COLOR_EDGE; |
|---|
| 608 | } |
|---|
| 609 | } |
|---|
| 610 | i_xSize++; |
|---|
| 611 | i_ySize++; |
|---|
| 612 | task->emulSmooth = 0; |
|---|
| 613 | } |
|---|
| 614 | |
|---|
| 615 | /* |
|---|
| 616 | static void utd_ImageExpand(UT_IMAGE* sImage, UT_IMAGE* dImage, int expand) |
|---|
| 617 | { |
|---|
| 618 | int y; |
|---|
| 619 | unsigned char* s_data = sImage->data; |
|---|
| 620 | unsigned char* d_data = dImage->data; |
|---|
| 621 | int s_sx = sImage->bbox.sx; |
|---|
| 622 | int s_sy = sImage->bbox.sy; |
|---|
| 623 | int d_sx = s_sx + expand + expand; |
|---|
| 624 | int d_sy = s_sy + expand + expand; |
|---|
| 625 | int s_bSize = sImage->bSize; |
|---|
| 626 | int d_bSize = ut_BALIGN(d_sx); |
|---|
| 627 | dImage->type = _UT_IMAGE_TYPE_BITMAP_65; |
|---|
| 628 | dImage->bbox.ox = sImage->bbox.ox - expand; |
|---|
| 629 | dImage->bbox.oy = sImage->bbox.oy - expand; |
|---|
| 630 | dImage->bbox.sx = d_sx; |
|---|
| 631 | dImage->bbox.sy = d_sy; |
|---|
| 632 | dImage->width = sImage->width; |
|---|
| 633 | dImage->height = sImage->height; |
|---|
| 634 | dImage->bSize = d_bSize; |
|---|
| 635 | dImage->lSize = d_bSize * d_sy; |
|---|
| 636 | UT_MEMSET(d_data, 0, dImage->lSize); |
|---|
| 637 | d_data += d_bSize * expand + expand; |
|---|
| 638 | for (y=0; y<s_sy; y++) |
|---|
| 639 | { |
|---|
| 640 | UT_MEMCPY(d_data, s_data, s_bSize); |
|---|
| 641 | d_data += d_bSize; |
|---|
| 642 | s_data += s_bSize; |
|---|
| 643 | } |
|---|
| 644 | } |
|---|
| 645 | |
|---|
| 646 | static void utd_ImageScaleUp(UT_IMAGE* sImage, UT_IMAGE* dImage, int xQuad, int yQuad) |
|---|
| 647 | { |
|---|
| 648 | int x, y, i, j; |
|---|
| 649 | unsigned char* s_data = sImage->data; |
|---|
| 650 | unsigned char* d_data = dImage->data; |
|---|
| 651 | int s_sx = sImage->bbox.sx; |
|---|
| 652 | int s_sy = sImage->bbox.sy; |
|---|
| 653 | int d_sx = (s_sx+2) * xQuad; |
|---|
| 654 | int d_sy = (s_sy+2) * yQuad; |
|---|
| 655 | int s_bSize = sImage->bSize; |
|---|
| 656 | int d_bSize = ut_BALIGN(d_sx); |
|---|
| 657 | dImage->type = _UT_IMAGE_TYPE_BITMAP_65; |
|---|
| 658 | dImage->bbox.ox = (sImage->bbox.ox-1) * xQuad; |
|---|
| 659 | dImage->bbox.oy = (sImage->bbox.oy-1) * yQuad; |
|---|
| 660 | dImage->bbox.sx = d_sx; |
|---|
| 661 | dImage->bbox.sy = d_sy; |
|---|
| 662 | dImage->width = sImage->width * xQuad; |
|---|
| 663 | dImage->height = sImage->height * yQuad; |
|---|
| 664 | dImage->bSize = d_bSize; |
|---|
| 665 | dImage->lSize = d_bSize * d_sy; |
|---|
| 666 | UT_MEMSET(d_data, 0, dImage->lSize); |
|---|
| 667 | d_data += d_bSize * yQuad + xQuad; |
|---|
| 668 | for (y=0; y<s_sy; y++) |
|---|
| 669 | { |
|---|
| 670 | for (i=0; i<yQuad; i++) |
|---|
| 671 | { |
|---|
| 672 | for (x=0; x<s_sx; x++) |
|---|
| 673 | { |
|---|
| 674 | if (!s_data[x]) continue; |
|---|
| 675 | for (j=0; j<xQuad; j++) |
|---|
| 676 | { |
|---|
| 677 | d_data[x*xQuad+j] = s_data[x]; |
|---|
| 678 | } |
|---|
| 679 | } |
|---|
| 680 | d_data += d_bSize; |
|---|
| 681 | } |
|---|
| 682 | s_data += s_bSize; |
|---|
| 683 | } |
|---|
| 684 | } |
|---|
| 685 | |
|---|
| 686 | static void utd_ImageScaleDown(UT_IMAGE* sImage, UT_IMAGE* dImage, int xQuad, int yQuad) |
|---|
| 687 | { |
|---|
| 688 | int x, y, i, j, div = xQuad*yQuad*64; |
|---|
| 689 | unsigned char* s_data = sImage->data; |
|---|
| 690 | unsigned char* d_data = dImage->data; |
|---|
| 691 | int s_sx = sImage->bbox.sx; |
|---|
| 692 | int s_sy = sImage->bbox.sy; |
|---|
| 693 | int d_sx = s_sx / xQuad; |
|---|
| 694 | int d_sy = s_sy / yQuad; |
|---|
| 695 | int s_bSize = sImage->bSize; |
|---|
| 696 | int d_bSize = ut_BALIGN(d_sx); |
|---|
| 697 | dImage->type = _UT_IMAGE_TYPE_BITMAP_65; |
|---|
| 698 | dImage->bbox.ox = sImage->bbox.ox / xQuad; |
|---|
| 699 | dImage->bbox.oy = sImage->bbox.oy / yQuad; |
|---|
| 700 | dImage->bbox.sx = d_sx; |
|---|
| 701 | dImage->bbox.sy = d_sy; |
|---|
| 702 | dImage->width = sImage->width / xQuad; |
|---|
| 703 | dImage->height = sImage->height / yQuad; |
|---|
| 704 | dImage->bSize = d_bSize; |
|---|
| 705 | dImage->lSize = d_bSize * d_sy; |
|---|
| 706 | UT_MEMSET(d_data, 0, dImage->lSize); |
|---|
| 707 | for (y=0; y<d_sy; y++) |
|---|
| 708 | { |
|---|
| 709 | for (x=0; x<s_sx; x++) |
|---|
| 710 | { |
|---|
| 711 | int sum = 0; |
|---|
| 712 | for (i=0; i<yQuad; i++) |
|---|
| 713 | { |
|---|
| 714 | for (j=0; j<xQuad; j++) |
|---|
| 715 | { |
|---|
| 716 | sum += s_data[i*s_bSize + x*xQuad+j]; |
|---|
| 717 | } |
|---|
| 718 | } |
|---|
| 719 | d_data[x] = sum * 64 / div; |
|---|
| 720 | } |
|---|
| 721 | d_data += d_bSize; |
|---|
| 722 | s_data += s_bSize*yQuad; |
|---|
| 723 | } |
|---|
| 724 | } |
|---|
| 725 | |
|---|
| 726 | static void utd_ImageBorder(UT_IMAGE* image, int level) |
|---|
| 727 | { |
|---|
| 728 | int x, y; |
|---|
| 729 | int xSize = image->bbox.sx - 1; |
|---|
| 730 | int ySize = image->bbox.sy - 1; |
|---|
| 731 | int bSize = image->bSize; |
|---|
| 732 | unsigned char* d = image->data; |
|---|
| 733 | unsigned char* s = image->data + bSize; |
|---|
| 734 | for (y=1; y<ySize; y++) |
|---|
| 735 | { |
|---|
| 736 | for (x=1; x<xSize; x++) |
|---|
| 737 | { |
|---|
| 738 | if (!s[x]) continue; |
|---|
| 739 | if (s[x] == 255) continue; |
|---|
| 740 | if (!s[x-1]) s[x-1] = 255; |
|---|
| 741 | if (!s[x+1]) s[x+1] = 255; |
|---|
| 742 | if (!s[x-bSize]) s[x-bSize] = 255; |
|---|
| 743 | if (!s[x+bSize]) s[x+bSize] = 255; |
|---|
| 744 | if (!s[x-bSize-1]) s[x-bSize-1] = 255; |
|---|
| 745 | if (!s[x-bSize+1]) s[x-bSize+1] = 255; |
|---|
| 746 | if (!s[x+bSize-1]) s[x+bSize-1] = 255; |
|---|
| 747 | if (!s[x+bSize+1]) s[x+bSize+1] = 255; |
|---|
| 748 | } |
|---|
| 749 | s += bSize; |
|---|
| 750 | } |
|---|
| 751 | for (y=image->lSize-1; y>=0; y--) |
|---|
| 752 | { |
|---|
| 753 | if (d[y] == 255) d[y] = level; |
|---|
| 754 | } |
|---|
| 755 | } |
|---|
| 756 | |
|---|
| 757 | static void utd_ImageCornering12(UT_IMAGE* image, int level1, int level2) |
|---|
| 758 | { |
|---|
| 759 | int level3; |
|---|
| 760 | int x, y; |
|---|
| 761 | int xSize = image->bbox.sx - 2; |
|---|
| 762 | int ySize = image->bbox.sy - 2; |
|---|
| 763 | int bSize = image->bSize; |
|---|
| 764 | unsigned char* d = image->data; |
|---|
| 765 | unsigned char* s = image->data + bSize + bSize; |
|---|
| 766 | for (y=2; y<ySize; y++) |
|---|
| 767 | { |
|---|
| 768 | for (x=2; x<xSize; x++) |
|---|
| 769 | { |
|---|
| 770 | unsigned char* ss = s + x; |
|---|
| 771 | unsigned char* p1 = ss + bSize; |
|---|
| 772 | unsigned char* p2 = p1 + bSize; |
|---|
| 773 | unsigned char* n1 = ss - bSize; |
|---|
| 774 | unsigned char* n2 = n1 - bSize; |
|---|
| 775 | if (*ss) continue; |
|---|
| 776 | if ((ss[+1] == 64) && (p1[0] == 64)) |
|---|
| 777 | { |
|---|
| 778 | if ((ss[-2] == 0) && (p1[-2] == 64) && |
|---|
| 779 | (ss[-1] == 0) && (p1[-1] == 64) && (n1[0] == 0) && (n1[+1] == 0)) |
|---|
| 780 | { |
|---|
| 781 | ss[0] = 251; |
|---|
| 782 | ss[-1] = 252; |
|---|
| 783 | } |
|---|
| 784 | else if ((n2[0] == 0) && (n2[+1] == 64) && |
|---|
| 785 | (n1[0] == 0) && (n1[+1] == 64) && (ss[-1] == 0) && (p1[-1] == 0)) |
|---|
| 786 | { |
|---|
| 787 | ss[0] = 251; |
|---|
| 788 | n1[0] = 252; |
|---|
| 789 | } |
|---|
| 790 | else |
|---|
| 791 | { |
|---|
| 792 | ss[0] = 253; |
|---|
| 793 | } |
|---|
| 794 | } |
|---|
| 795 | else if ((ss[+1] == 64) && (n1[0] == 64)) |
|---|
| 796 | { |
|---|
| 797 | if ((ss[-2] == 0) && (n1[-2] == 64) && |
|---|
| 798 | (ss[-1] == 0) && (n1[-1] == 64) && (p1[0] == 0) && (p1[+1] == 0)) |
|---|
| 799 | { |
|---|
| 800 | ss[0] = 251; |
|---|
| 801 | ss[-1] = 252; |
|---|
| 802 | } |
|---|
| 803 | else if ((p2[0] == 0) && (p2[+1] == 64) && |
|---|
| 804 | (p1[0] == 0) && (p1[+1] == 64) && (ss[-1] == 0) && (n1[-1] == 0)) |
|---|
| 805 | { |
|---|
| 806 | ss[0] = 251; |
|---|
| 807 | n1[0] = 252; |
|---|
| 808 | } |
|---|
| 809 | else |
|---|
| 810 | { |
|---|
| 811 | ss[0] = 253; |
|---|
| 812 | } |
|---|
| 813 | } |
|---|
| 814 | else if ((ss[-1] == 64) && (p1[0] == 64)) |
|---|
| 815 | { |
|---|
| 816 | if ((ss[+2] == 0) && (p1[+2] == 64) && |
|---|
| 817 | (ss[+1] == 0) && (p1[+1] == 64) && (n1[0] == 0) && (n1[-1] == 0)) |
|---|
| 818 | { |
|---|
| 819 | ss[0] = 251; |
|---|
| 820 | ss[+1] = 252; |
|---|
| 821 | } |
|---|
| 822 | else if ((n2[0] == 0) && (n2[-1] == 64) && |
|---|
| 823 | (n1[0] == 0) && (n1[-1] == 64) && (ss[+1] == 0) && (p1[+1] == 0)) |
|---|
| 824 | { |
|---|
| 825 | ss[0] = 251; |
|---|
| 826 | n1[0] = 252; |
|---|
| 827 | } |
|---|
| 828 | else |
|---|
| 829 | { |
|---|
| 830 | ss[0] = 253; |
|---|
| 831 | } |
|---|
| 832 | } |
|---|
| 833 | else if ((ss[-1] == 64) && (n1[0] == 64)) |
|---|
| 834 | { |
|---|
| 835 | if ((ss[+2] == 0) && (n1[+2] == 64) && |
|---|
| 836 | (ss[+1] == 0) && (n1[+1] == 64) && (p1[0] == 0) && (p1[-1] == 0)) |
|---|
| 837 | { |
|---|
| 838 | ss[0] = 251; |
|---|
| 839 | ss[+1] = 252; |
|---|
| 840 | } |
|---|
| 841 | else if ((p2[0] == 0) && (p2[-1] == 64) && |
|---|
| 842 | (p1[0] == 0) && (p1[-1] == 64) && (ss[+1] == 0) && (n1[+1] == 0)) |
|---|
| 843 | { |
|---|
| 844 | ss[0] = 251; |
|---|
| 845 | n1[0] = 252; |
|---|
| 846 | } |
|---|
| 847 | else |
|---|
| 848 | { |
|---|
| 849 | ss[0] = 253; |
|---|
| 850 | } |
|---|
| 851 | } |
|---|
| 852 | } |
|---|
| 853 | s += bSize; |
|---|
| 854 | } |
|---|
| 855 | for (y=image->lSize-1; y>=0; y--) |
|---|
| 856 | { |
|---|
| 857 | if (d[y] == 251) d[y] = level1; |
|---|
| 858 | else if (d[y] == 252) d[y] = level2; |
|---|
| 859 | else if (d[y] == 253) d[y] = level3; |
|---|
| 860 | } |
|---|
| 861 | } |
|---|
| 862 | |
|---|
| 863 | static void utd_ImageCornering1(UT_IMAGE* image, int level1) |
|---|
| 864 | { |
|---|
| 865 | int x, y; |
|---|
| 866 | int xSize = image->bbox.sx - 1; |
|---|
| 867 | int ySize = image->bbox.sy - 1; |
|---|
| 868 | int bSize = image->bSize; |
|---|
| 869 | unsigned char* d = image->data; |
|---|
| 870 | unsigned char* s = image->data + bSize; |
|---|
| 871 | for (y=1; y<ySize; y++) |
|---|
| 872 | { |
|---|
| 873 | for (x=1; x<xSize; x++) |
|---|
| 874 | { |
|---|
| 875 | if (s[x]) continue; |
|---|
| 876 | if ((s[x-1] == 64) && (s[x-bSize] == 64)) |
|---|
| 877 | { |
|---|
| 878 | s[x] = 251; |
|---|
| 879 | } |
|---|
| 880 | else if ((s[x-1] == 64) && (s[x+bSize] == 64)) |
|---|
| 881 | { |
|---|
| 882 | s[x] = 251; |
|---|
| 883 | } |
|---|
| 884 | if ((s[x+1] == 64) && (s[x-bSize] == 64)) |
|---|
| 885 | { |
|---|
| 886 | s[x] = 251; |
|---|
| 887 | } |
|---|
| 888 | else if ((s[x+1] == 64) && (s[x+bSize] == 64)) |
|---|
| 889 | { |
|---|
| 890 | s[x] = 251; |
|---|
| 891 | } |
|---|
| 892 | } |
|---|
| 893 | s += bSize; |
|---|
| 894 | } |
|---|
| 895 | for (y=image->lSize-1; y>=0; y--) |
|---|
| 896 | { |
|---|
| 897 | if (d[y] == 251) d[y] = level1; |
|---|
| 898 | } |
|---|
| 899 | } |
|---|
| 900 | |
|---|
| 901 | static void utd_ImageCornering2(UT_IMAGE* image, int level1, int level2) |
|---|
| 902 | { |
|---|
| 903 | int x, y; |
|---|
| 904 | int xSize = image->bbox.sx - 1; |
|---|
| 905 | int ySize = image->bbox.sy - 1; |
|---|
| 906 | int bSize = image->bSize; |
|---|
| 907 | unsigned char* d = image->data; |
|---|
| 908 | unsigned char* s = image->data + bSize; |
|---|
| 909 | for (y=1; y<ySize; y++) |
|---|
| 910 | { |
|---|
| 911 | for (x=1; x<xSize; x++) |
|---|
| 912 | { |
|---|
| 913 | if (s[x]) continue; |
|---|
| 914 | if ((s[x-1] == 64) && (s[x-bSize] == 64)) |
|---|
| 915 | { |
|---|
| 916 | s[x] = 251; |
|---|
| 917 | s[x+1] = 252; |
|---|
| 918 | s[x+0+bSize] = 252; |
|---|
| 919 | } |
|---|
| 920 | else if ((s[x-1] == 64) && (s[x+bSize] == 64)) |
|---|
| 921 | { |
|---|
| 922 | s[x] = 251; |
|---|
| 923 | s[x+1] = 252; |
|---|
| 924 | s[x+0-bSize] = 252; |
|---|
| 925 | } |
|---|
| 926 | if ((s[x+1] == 64) && (s[x-bSize] == 64)) |
|---|
| 927 | { |
|---|
| 928 | s[x] = 251; |
|---|
| 929 | s[x-1] = 252; |
|---|
| 930 | s[x-0+bSize] = 252; |
|---|
| 931 | } |
|---|
| 932 | else if ((s[x+1] == 64) && (s[x+bSize] == 64)) |
|---|
| 933 | { |
|---|
| 934 | s[x] = 251; |
|---|
| 935 | s[x-1] = 252; |
|---|
| 936 | s[x-0-bSize] = 252; |
|---|
| 937 | } |
|---|
| 938 | } |
|---|
| 939 | s += bSize; |
|---|
| 940 | } |
|---|
| 941 | for (y=image->lSize-1; y>=0; y--) |
|---|
| 942 | { |
|---|
| 943 | if (d[y] == 251) d[y] = level1; |
|---|
| 944 | if (d[y] == 252) d[y] = level2; |
|---|
| 945 | } |
|---|
| 946 | } |
|---|
| 947 | |
|---|
| 948 | static void utd_ImageCornering3(UT_IMAGE* image, int level1, int level2, int level3) |
|---|
| 949 | { |
|---|
| 950 | int x, y; |
|---|
| 951 | int xSize = image->bbox.sx - 1; |
|---|
| 952 | int ySize = image->bbox.sy - 1; |
|---|
| 953 | int bSize = image->bSize; |
|---|
| 954 | unsigned char* d = image->data; |
|---|
| 955 | unsigned char* s = image->data + bSize; |
|---|
| 956 | for (y=1; y<ySize; y++) |
|---|
| 957 | { |
|---|
| 958 | for (x=1; x<xSize; x++) |
|---|
| 959 | { |
|---|
| 960 | if (s[x]) continue; |
|---|
| 961 | if ((s[x-1] == 64) && (s[x-bSize] == 64)) |
|---|
| 962 | { |
|---|
| 963 | s[x] = 251; |
|---|
| 964 | s[x+1] = 252; |
|---|
| 965 | s[x+0+bSize] = 252; |
|---|
| 966 | s[x+2] = 253; |
|---|
| 967 | s[x+1+bSize] = 253; |
|---|
| 968 | s[x+0+bSize+bSize] = 253; |
|---|
| 969 | } |
|---|
| 970 | else if ((s[x-1] == 64) && (s[x+bSize] == 64)) |
|---|
| 971 | { |
|---|
| 972 | s[x] = 251; |
|---|
| 973 | s[x+1] = 252; |
|---|
| 974 | s[x+0-bSize] = 252; |
|---|
| 975 | s[x+2] = 253; |
|---|
| 976 | s[x+1-bSize] = 253; |
|---|
| 977 | s[x+0-bSize-bSize] = 253; |
|---|
| 978 | } |
|---|
| 979 | if ((s[x+1] == 64) && (s[x-bSize] == 64)) |
|---|
| 980 | { |
|---|
| 981 | s[x] = 251; |
|---|
| 982 | s[x-1] = 252; |
|---|
| 983 | s[x-0+bSize] = 252; |
|---|
| 984 | s[x-2] = 253; |
|---|
| 985 | s[x-1+bSize] = 253; |
|---|
| 986 | s[x-0+bSize+bSize] = 253; |
|---|
| 987 | } |
|---|
| 988 | else if ((s[x+1] == 64) && (s[x+bSize] == 64)) |
|---|
| 989 | { |
|---|
| 990 | s[x] = 251; |
|---|
| 991 | s[x-1] = 252; |
|---|
| 992 | s[x-0-bSize] = 252; |
|---|
| 993 | s[x-2] = 253; |
|---|
| 994 | s[x-1-bSize] = 253; |
|---|
| 995 | s[x-0-bSize-bSize] = 253; |
|---|
| 996 | } |
|---|
| 997 | } |
|---|
| 998 | s += bSize; |
|---|
| 999 | } |
|---|
| 1000 | for (y=image->lSize-1; y>=0; y--) |
|---|
| 1001 | { |
|---|
| 1002 | if (d[y] == 251) d[y] = level1; |
|---|
| 1003 | if (d[y] == 252) d[y] = level2; |
|---|
| 1004 | if (d[y] == 253) d[y] = level3; |
|---|
| 1005 | } |
|---|
| 1006 | } |
|---|
| 1007 | |
|---|
| 1008 | static void utd_ImageAntialaisingA() |
|---|
| 1009 | { |
|---|
| 1010 | UT_IMAGE temp; temp.data = staticAntialaisingBuffer; |
|---|
| 1011 | utd_ImageScaleUp(&ut_image, &temp, _A_QUAD, _A_QUAD); |
|---|
| 1012 | utd_ImageBorder(&temp, 48); |
|---|
| 1013 | utd_ImageScaleDown(&temp, &ut_image, _A_QUAD, _A_QUAD); |
|---|
| 1014 | } |
|---|
| 1015 | |
|---|
| 1016 | static void utd_ImageAntialaisingB() |
|---|
| 1017 | { |
|---|
| 1018 | UT_IMAGE temp; temp.data = staticAntialaisingBuffer; |
|---|
| 1019 | utd_ImageScaleUp(&ut_image, &temp, _A_QUAD, _A_QUAD); |
|---|
| 1020 | utd_ImageCornering3(&temp, 64, 64, 0); |
|---|
| 1021 | utd_ImageBorder(&temp, 32); |
|---|
| 1022 | utd_ImageScaleDown(&temp, &ut_image, _A_QUAD, _A_QUAD); |
|---|
| 1023 | } |
|---|
| 1024 | |
|---|
| 1025 | static void utd_ImageAntialaisingC() |
|---|
| 1026 | { |
|---|
| 1027 | UT_IMAGE temp; temp.data = staticAntialaisingBuffer; |
|---|
| 1028 | utd_ImageExpand(&ut_image, &temp, 2); |
|---|
| 1029 | utd_ImageCornering12(&temp, 32, 16); |
|---|
| 1030 | //utd_ImageBorder(&temp, 10); |
|---|
| 1031 | ut_image = temp; |
|---|
| 1032 | } |
|---|
| 1033 | |
|---|
| 1034 | */ |
|---|
| 1035 | |
|---|
| 1036 | #endif /*#ifndef _INCLUDED_BITMAP_EFFECT*/ |
|---|