1785 |
1785 |
1786 // ============================================================================= |
1786 // ============================================================================= |
1787 // |
1787 // |
1788 void GLRenderer::zoomToFit() |
1788 void GLRenderer::zoomToFit() |
1789 { |
1789 { |
|
1790 print ("zooming %1 to fit..\n", camera()); |
|
1791 zoom() = 30.0f; |
|
1792 |
1790 if (document() == null || m_width == -1 || m_height == -1) |
1793 if (document() == null || m_width == -1 || m_height == -1) |
1791 { |
1794 { |
1792 zoom() = 30.0f; |
1795 print ("document is invalid!\n"); |
1793 return; |
1796 return; |
1794 } |
1797 } |
1795 |
1798 |
1796 bool lastfilled = false; |
1799 bool lastfilled = false; |
1797 bool firstrun = true; |
1800 bool firstrun = true; |
1829 for (int i = 0; i < w; ++i) |
1832 for (int i = 0; i < w; ++i) |
1830 { |
1833 { |
1831 if (imgdata[i] != white || imgdata[((h - 1) * w) + i] != white) |
1834 if (imgdata[i] != white || imgdata[((h - 1) * w) + i] != white) |
1832 { |
1835 { |
1833 filled = true; |
1836 filled = true; |
1834 goto endOfLoop; |
1837 break; |
1835 } |
1838 } |
1836 } |
1839 } |
1837 |
1840 |
1838 // Left and right edges |
1841 // Left and right edges |
1839 for (int i = 0; i < h; ++i) |
1842 if (filled == false) |
1840 { |
1843 { |
1841 if (imgdata[i * w] != white || imgdata[(i * w) + w - 1] != white) |
1844 for (int i = 0; i < h; ++i) |
1842 { |
1845 { |
1843 filled = true; |
1846 if (imgdata[i * w] != white || imgdata[(i * w) + w - 1] != white) |
1844 goto endOfLoop; |
1847 { |
|
1848 filled = true; |
|
1849 break; |
|
1850 } |
1845 } |
1851 } |
1846 } |
1852 } |
1847 |
|
1848 endOfLoop: |
|
1849 |
1853 |
1850 delete[] cap; |
1854 delete[] cap; |
1851 |
1855 |
1852 if (firstrun) |
1856 if (firstrun) |
1853 { |
1857 { |