From 5b6c824773df2a12deba1c9b49e3c5d5608facfd Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Fri, 7 Oct 2011 08:03:24 +0200 Subject: [PATCH] Fixed error in subrect adjustment in Texture::LoadFromImage --- src/SFML/Graphics/Texture.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index b7a80d335..202b19683 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -188,8 +188,8 @@ bool Texture::LoadFromImage(const Image& image, const IntRect& area) IntRect rectangle = area; if (rectangle.Left < 0) rectangle.Left = 0; if (rectangle.Top < 0) rectangle.Top = 0; - if (rectangle.Width > width) rectangle.Width = width; - if (rectangle.Height > height) rectangle.Height = height; + if (rectangle.Left + rectangle.Width > width) rectangle.Width = width - rectangle.Left; + if (rectangle.Top + rectangle.Height > height) rectangle.Height = height - rectangle.Top; // Create the texture and upload the pixels if (Create(rectangle.Width, rectangle.Height))