()
| 1911 | } |
| 1912 | |
| 1913 | private void loadBase64Image(){ |
| 1914 | String[] parts = this.imagePath.split(";base64,"); |
| 1915 | String extension = parts[0].substring(11); |
| 1916 | String encodedData = parts[1]; |
| 1917 | |
| 1918 | byte[] decodedBytes = DatatypeConverter.parseBase64Binary(encodedData); |
| 1919 | |
| 1920 | if(decodedBytes == null){ |
| 1921 | System.err.println("Decode Error on image: " + imagePath.substring(0, 20)); |
| 1922 | return; |
| 1923 | } |
| 1924 | |
| 1925 | Image awtImage = new ImageIcon(decodedBytes).getImage(); |
| 1926 | |
| 1927 | if (awtImage instanceof BufferedImage) { |
| 1928 | BufferedImage buffImage = (BufferedImage) awtImage; |
| 1929 | int space = buffImage.getColorModel().getColorSpace().getType(); |
| 1930 | if (space == ColorSpace.TYPE_CMYK) { |
| 1931 | return; |
| 1932 | } |
| 1933 | } |
| 1934 | |
| 1935 | PImage loadedImage = new PImage(awtImage); |
| 1936 | if (loadedImage.width == -1) { |
| 1937 | // error... |
| 1938 | } |
| 1939 | |
| 1940 | // if it's a .gif image, test to see if it has transparency |
| 1941 | if (extension.equals("gif") || extension.equals("png") || |
| 1942 | extension.equals("unknown")) { |
| 1943 | loadedImage.checkAlpha(); |
| 1944 | } |
| 1945 | |
| 1946 | setTexture(loadedImage); |
| 1947 | } |
| 1948 | |
| 1949 | // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
| 1950 |
no test coverage detected