| 95 | // Allocate or reallocate a 24 bit color bitmap to have a given size. |
| 96 | |
| 97 | flag FAllocateBmp(Bitmap *b, int x, int y) |
| 98 | { |
| 99 | char sz[cchSzDef]; |
| 100 | long cb; |
| 101 | byte *rgb; |
| 102 | |
| 103 | if (x == b->x && y == b->y) |
| 104 | return fTrue; |
| 105 | if (x < 0 || y < 0 || x > zColmap || y > zColmap) { |
| 106 | sprintf(sz, "Can't create color bitmap larger than %d by %d!\n", |
| 107 | zColmap, zColmap); |
| 108 | PrintError(sz); |
| 109 | return fFalse; |
| 110 | } |
| 111 | cb = CbColmap(x, y); |
| 112 | if (cb < 0) { |
| 113 | sprintf(sz, "Can't allocate color bitmap of size %d by %d!\n", x, y); |
| 114 | PrintError(sz); |
| 115 | return fFalse; |
| 116 | } |
| 117 | if (cb != CbColmap(b->x, b->y)) { |
| 118 | rgb = (byte *)PAllocate(cb, "color bitmap"); |
| 119 | if (rgb == NULL) |
| 120 | return fFalse; |
| 121 | DeallocatePIf(b->rgb); |
| 122 | b->rgb = rgb; |
| 123 | } |
| 124 | b->x = x; b->y = y; |
| 125 | b->clRow = CbColmapRow(x) >> 2; |
| 126 | return fTrue; |
| 127 | } |
| 128 | |
| 129 | |
| 130 | // Load a bitmap from file into a 24 bit bitmap structure. This supports |
no test coverage detected