| 1878 | /// |
| 1879 | /// a new image (or the same image if dimensions happen to match) filling the width/height |
| 1880 | public Image fill(int width, int height) { |
| 1881 | if (getWidth() == width && getHeight() == height) { |
| 1882 | return this; |
| 1883 | } |
| 1884 | Image nimage = scaledLargerRatio(width, height); |
| 1885 | if (nimage.getWidth() > width) { |
| 1886 | int diff = nimage.getWidth() - width; |
| 1887 | nimage = nimage.subImage(diff / 2, 0, width, height, true); |
| 1888 | } else { |
| 1889 | if (nimage.getHeight() > height) { |
| 1890 | int diff = nimage.getHeight() - height; |
| 1891 | nimage = nimage.subImage(0, diff / 2, width, height, true); |
| 1892 | } |
| 1893 | } |
| 1894 | return nimage; |
| 1895 | } |
| 1896 | |
| 1897 | /// Returns the platform specific image implementation, **warning** the |
| 1898 | /// implementation class can change between revisions of Codename One and platforms. |