diff --git a/src/thothbot/parallax/core/client/renderers/WebGLRenderer.java b/src/thothbot/parallax/core/client/renderers/WebGLRenderer.java index cab3167e..30b17798 100644 --- a/src/thothbot/parallax/core/client/renderers/WebGLRenderer.java +++ b/src/thothbot/parallax/core/client/renderers/WebGLRenderer.java @@ -2981,8 +2981,8 @@ public void setTexture( Texture texture, int slot ) getGL().pixelStorei( PixelStoreParameter.UNPACK_ALIGNMENT, texture.getUnpackAlignment() ); Element image = texture.getImage(); - boolean isImagePowerOfTwo = Mathematics.isPowerOfTwo( image.getOffsetWidth() ) - && Mathematics.isPowerOfTwo( image.getOffsetHeight() ); + boolean isImagePowerOfTwo = Mathematics.isPowerOfTwo( texture.getWidth() ) + && Mathematics.isPowerOfTwo( texture.getHeight() ); texture.setTextureParameters( getGL(), getMaxAnisotropy(), TextureTarget.TEXTURE_2D, isImagePowerOfTwo ); @@ -3029,6 +3029,10 @@ private CanvasElement createPowerOfTwoImage(Element image) { int width = image.getOffsetWidth(); int height = image.getOffsetHeight(); + if (width == 0 && height == 0) { + width = image.getPropertyInt("width"); + height = image.getPropertyInt("height"); + } CanvasElement canvas = Document.get().createElement("canvas").cast(); @@ -3055,6 +3059,10 @@ private Element clampToMaxSize ( Element image, int maxSize ) { int imgWidth = image.getOffsetWidth(); int imgHeight = image.getOffsetHeight(); + if (imgWidth == 0 && imgHeight == 0) { + imgWidth = image.getPropertyInt("width"); + imgHeight = image.getPropertyInt("height"); + } if ( imgWidth <= maxSize && imgHeight <= maxSize ) return image; diff --git a/src/thothbot/parallax/core/client/textures/Texture.java b/src/thothbot/parallax/core/client/textures/Texture.java index 2b8a5c65..6b71033d 100644 --- a/src/thothbot/parallax/core/client/textures/Texture.java +++ b/src/thothbot/parallax/core/client/textures/Texture.java @@ -328,6 +328,32 @@ public void setImage(Element image) { this.image = image; } + /** + * Gets texture width. + * + * @return the texture width. + */ + public int getWidth() { + int width = image.getOffsetWidth(); + if (width == 0) { + width = image.getPropertyInt("width"); + } + return width; + } + + /** + * Gets texture height. + * + * @return the texture height. + */ + public int getHeight() { + int height = image.getOffsetHeight(); + if (height == 0) { + height = image.getPropertyInt("height"); + } + return height; + } + /** * Gets texture offset. *