given a chunked bitmap, renders it.scaled
| 324 | |
| 325 | // given a chunked bitmap, renders it.scaled |
| 326 | void rend_DrawScaledChunkedBitmap(chunked_bitmap *chunk, int x, int y, int neww, int newh, uint8_t alpha) { |
| 327 | int *bm_array = chunk->bm_array; |
| 328 | int w = chunk->w; |
| 329 | int h = chunk->h; |
| 330 | int piece_w; |
| 331 | int piece_h; |
| 332 | int screen_w, screen_h; |
| 333 | int i, t; |
| 334 | |
| 335 | float scalew, scaleh; |
| 336 | |
| 337 | scalew = ((float)neww) / ((float)chunk->pw); |
| 338 | scaleh = ((float)newh) / ((float)chunk->ph); |
| 339 | piece_w = scalew * ((float)bm_w(bm_array[0], 0)); |
| 340 | piece_h = scaleh * ((float)bm_h(bm_array[0], 0)); |
| 341 | rend_GetProjectionParameters(&screen_w, &screen_h); |
| 342 | rend_SetOverlayType(OT_NONE); |
| 343 | rend_SetLighting(LS_NONE); |
| 344 | rend_SetColorModel(CM_MONO); |
| 345 | rend_SetZBufferState(0); |
| 346 | rend_SetAlphaType(AT_CONSTANT_TEXTURE); |
| 347 | rend_SetAlphaValue(alpha); |
| 348 | rend_SetWrapType(WT_WRAP); |
| 349 | for (i = 0; i < h; i++) { |
| 350 | for (t = 0; t < w; t++) { |
| 351 | int dx = x + (piece_w * t); |
| 352 | int dy = y + (piece_h * i); |
| 353 | int dw, dh; |
| 354 | if ((dx + piece_w) > screen_w) |
| 355 | dw = piece_w - ((dx + piece_w) - screen_w); |
| 356 | else |
| 357 | dw = piece_w; |
| 358 | if ((dy + piece_h) > screen_h) |
| 359 | dh = piece_h - ((dy + piece_h) - screen_h); |
| 360 | else |
| 361 | dh = piece_h; |
| 362 | |
| 363 | float u2 = (float)dw / (float)piece_w; |
| 364 | float v2 = (float)dh / (float)piece_h; |
| 365 | rend_DrawScaledBitmap(dx, dy, dx + dw, dy + dh, bm_array[i * w + t], 0, 0, u2, v2); |
| 366 | } |
| 367 | } |
| 368 | rend_SetZBufferState(1); |
| 369 | } |
| 370 | |
| 371 | // Sets some global preferences for the renderer |
| 372 | int rend_SetPreferredState(renderer_preferred_state *pref_state) { |
no test coverage detected