mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 15:11:37 +00:00
* Source/NSImage.m (-nativeDrawInRect:...): Fix two bugs
demonstrated in GSTest: - drawing an image in a flipped view with -drawInRect:... wasn't working, and - drawing a vector rep in a dest rect larger than the point size of the rep was resulting in blurry output. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33570 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7ace2baf52
commit
4e36d04d40
2 changed files with 38 additions and 7 deletions
|
@ -1,3 +1,12 @@
|
|||
2011-07-15 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/NSImage.m (-nativeDrawInRect:...): Fix two bugs
|
||||
demonstrated in GSTest:
|
||||
- drawing an image in a flipped view with -drawInRect:... wasn't
|
||||
working, and
|
||||
- drawing a vector rep in a dest rect larger than the point
|
||||
size of the rep was resulting in blurry output.
|
||||
|
||||
2011-07-15 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* configure.ac:
|
||||
|
|
|
@ -1017,17 +1017,39 @@ behavior precisely matches Cocoa. */
|
|||
NSGraphicsContext *cacheCtxt;
|
||||
NSSize repSize = [rep size];
|
||||
/* The size of the cache window that will hold the scaled image */
|
||||
NSSize cacheSize = [[ctxt GSCurrentCTM] transformSize: repSize];
|
||||
NSSize cacheSize;
|
||||
|
||||
CGFloat imgToCacheWidthScaleFactor = cacheSize.width / imgSize.width;
|
||||
CGFloat imgToCacheHeightScaleFactor = cacheSize.height / imgSize.height;
|
||||
CGFloat imgToCacheWidthScaleFactor;
|
||||
CGFloat imgToCacheHeightScaleFactor;;
|
||||
|
||||
NSRect srcRectInCache = NSMakeRect(srcRect.origin.x * imgToCacheWidthScaleFactor,
|
||||
srcRect.origin.y * imgToCacheHeightScaleFactor,
|
||||
srcRect.size.width * imgToCacheWidthScaleFactor,
|
||||
srcRect.size.height * imgToCacheHeightScaleFactor);
|
||||
NSRect srcRectInCache;
|
||||
NSAffineTransform *transform, *backup;
|
||||
|
||||
if (([rep pixelsWide] == NSImageRepMatchesDevice &&
|
||||
[rep pixelsHigh] == NSImageRepMatchesDevice) &&
|
||||
(dstRect.size.width > repSize.width ||
|
||||
dstRect.size.height > repSize.height))
|
||||
{
|
||||
cacheSize = [[ctxt GSCurrentCTM] transformSize: dstRect.size];
|
||||
}
|
||||
else
|
||||
{
|
||||
cacheSize = [[ctxt GSCurrentCTM] transformSize: repSize];
|
||||
}
|
||||
|
||||
if (cacheSize.width < 0)
|
||||
cacheSize.width *= -1;
|
||||
if (cacheSize.height < 0)
|
||||
cacheSize.height *= -1;
|
||||
|
||||
imgToCacheWidthScaleFactor = cacheSize.width / imgSize.width;
|
||||
imgToCacheHeightScaleFactor = cacheSize.height / imgSize.height;
|
||||
|
||||
srcRectInCache = NSMakeRect(srcRect.origin.x * imgToCacheWidthScaleFactor,
|
||||
srcRect.origin.y * imgToCacheHeightScaleFactor,
|
||||
srcRect.size.width * imgToCacheWidthScaleFactor,
|
||||
srcRect.size.height * imgToCacheHeightScaleFactor);
|
||||
|
||||
cache = [[NSCachedImageRep alloc]
|
||||
initWithSize: NSMakeSize(ceil(cacheSize.width), ceil(cacheSize.height))
|
||||
depth: [[NSScreen mainScreen] depth]
|
||||
|
|
Loading…
Reference in a new issue