crop the bitmap returning new dimensions
| 316 | |
| 317 | // crop the bitmap returning new dimensions |
| 318 | void Bmp8::Crop(int *xst, int *yst, int *wid, int *hgt) { |
| 319 | (*xst) = 0; |
| 320 | (*yst) = 0; |
| 321 | |
| 322 | int xend = wid_ - 1; |
| 323 | int yend = hgt_ - 1; |
| 324 | |
| 325 | while ((*xst) < (wid_ - 1) && (*xst) <= xend) { |
| 326 | // column is not empty |
| 327 | if (!IsBlankColumn((*xst))) { |
| 328 | break; |
| 329 | } |
| 330 | (*xst)++; |
| 331 | } |
| 332 | |
| 333 | while (xend > 0 && xend >= (*xst)) { |
| 334 | // column is not empty |
| 335 | if (!IsBlankColumn(xend)) { |
| 336 | break; |
| 337 | } |
| 338 | xend--; |
| 339 | } |
| 340 | |
| 341 | while ((*yst) < (hgt_ - 1) && (*yst) <= yend) { |
| 342 | // column is not empty |
| 343 | if (!IsBlankRow((*yst))) { |
| 344 | break; |
| 345 | } |
| 346 | (*yst)++; |
| 347 | } |
| 348 | |
| 349 | while (yend > 0 && yend >= (*yst)) { |
| 350 | // column is not empty |
| 351 | if (!IsBlankRow(yend)) { |
| 352 | break; |
| 353 | } |
| 354 | yend--; |
| 355 | } |
| 356 | |
| 357 | (*wid) = xend - (*xst) + 1; |
| 358 | (*hgt) = yend - (*yst) + 1; |
| 359 | } |
| 360 | |
| 361 | // generates a scaled bitmap with dimensions the new bmp will have the |
| 362 | // same aspect ratio and will be centered in the box |
no outgoing calls
no test coverage detected