| 447 | } |
| 448 | |
| 449 | QPixmap *Render::getCurrentDoublePage() |
| 450 | { |
| 451 | if (currentPageIsDoublePage()) { |
| 452 | QPoint leftpage(0, 0); |
| 453 | QPoint rightpage(0, 0); |
| 454 | QSize leftsize = buffer[currentPageBufferedIndex]->size(); |
| 455 | QSize rightsize = buffer[currentPageBufferedIndex + 1]->size(); |
| 456 | int totalWidth, totalHeight; |
| 457 | switch (imageRotation) { |
| 458 | case 0: |
| 459 | totalHeight = qMax(leftsize.rheight(), rightsize.rheight()); |
| 460 | leftsize.scale(leftsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding); |
| 461 | rightsize.scale(rightsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding); |
| 462 | totalWidth = leftsize.rwidth() + rightsize.rwidth(); |
| 463 | rightpage.setX(leftsize.rwidth()); |
| 464 | break; |
| 465 | case 90: |
| 466 | totalWidth = qMax(leftsize.rwidth(), rightsize.rwidth()); |
| 467 | leftsize.scale(totalWidth, leftsize.rheight(), Qt::KeepAspectRatioByExpanding); |
| 468 | rightsize.scale(totalWidth, rightsize.rheight(), Qt::KeepAspectRatioByExpanding); |
| 469 | totalHeight = leftsize.rheight() + rightsize.rheight(); |
| 470 | rightpage.setY(leftsize.rheight()); |
| 471 | break; |
| 472 | case 180: |
| 473 | totalHeight = qMax(leftsize.rheight(), rightsize.rheight()); |
| 474 | leftsize.scale(leftsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding); |
| 475 | rightsize.scale(rightsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding); |
| 476 | totalWidth = leftsize.rwidth() + rightsize.rwidth(); |
| 477 | leftpage.setX(rightsize.rwidth()); |
| 478 | break; |
| 479 | case 270: |
| 480 | totalWidth = qMax(leftsize.rwidth(), rightsize.rwidth()); |
| 481 | leftsize.scale(totalWidth, leftsize.rheight(), Qt::KeepAspectRatioByExpanding); |
| 482 | rightsize.scale(totalWidth, rightsize.rheight(), Qt::KeepAspectRatioByExpanding); |
| 483 | totalHeight = leftsize.rheight() + rightsize.rheight(); |
| 484 | leftpage.setY(rightsize.rheight()); |
| 485 | break; |
| 486 | default: |
| 487 | return nullptr; |
| 488 | } |
| 489 | auto page = new QPixmap(totalWidth, totalHeight); |
| 490 | QPainter painter(page); |
| 491 | painter.drawImage(QRect(leftpage, leftsize), *buffer[currentPageBufferedIndex]); |
| 492 | painter.drawImage(QRect(rightpage, rightsize), *buffer[currentPageBufferedIndex + 1]); |
| 493 | return page; |
| 494 | } else { |
| 495 | return nullptr; |
| 496 | } |
| 497 | } |
| 498 | |
| 499 | QPixmap *Render::getCurrentDoubleMangaPage() |
| 500 | { |