From 7f7341518938d42b55763d63a92f5e95677c312c Mon Sep 17 00:00:00 2001 From: andyque Date: Wed, 26 Aug 2015 16:15:00 +0800 Subject: [PATCH] fix Scale9Sprite draw extra pixels in spritesheet Fixed https://github.com/cocos2d/cocos2d-x/issues/13564 --- cocos/base/CCNinePatchImageParser.cpp | 5 +---- cocos/ui/UIScale9Sprite.cpp | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/cocos/base/CCNinePatchImageParser.cpp b/cocos/base/CCNinePatchImageParser.cpp index 8ed4c2bb55..9a33d7081b 100644 --- a/cocos/base/CCNinePatchImageParser.cpp +++ b/cocos/base/CCNinePatchImageParser.cpp @@ -184,10 +184,7 @@ Rect NinePatchImageParser::parseCapInset() const verticalLine.y - verticalLine.x); } - capInsets = Rect(capInsets.origin.x / CC_CONTENT_SCALE_FACTOR(), - capInsets.origin.y / CC_CONTENT_SCALE_FACTOR(), - capInsets.size.width / CC_CONTENT_SCALE_FACTOR(), - capInsets.size.height / CC_CONTENT_SCALE_FACTOR()); + capInsets = CC_RECT_PIXELS_TO_POINTS(capInsets); return capInsets; } diff --git a/cocos/ui/UIScale9Sprite.cpp b/cocos/ui/UIScale9Sprite.cpp index 7178b1a60a..eddf5bef5c 100644 --- a/cocos/ui/UIScale9Sprite.cpp +++ b/cocos/ui/UIScale9Sprite.cpp @@ -580,8 +580,8 @@ namespace ui { float width = _originalSize.width; float height = _originalSize.height; - Vec2 offsetPosition(ceilf(_offset.x + (_originalSize.width - _spriteRect.size.width) / 2), - ceilf(_offset.y + (_originalSize.height - _spriteRect.size.height) / 2)); + Vec2 offsetPosition(floor(_offset.x + (_originalSize.width - _spriteRect.size.width) / 2), + floor(_offset.y + (_originalSize.height - _spriteRect.size.height) / 2)); // If there is no specified center region if ( _capInsetsInternal.equals(Rect::ZERO) ) @@ -794,7 +794,7 @@ namespace ui { //shrink the image size when it is 9-patch if(_isPatch9) { - float offset = 1.4f; + float offset = 1.0f; //Top left if(!_spriteFrameRotated) {