mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 17:52:42 +00:00
Improve implementation of NSImage -bestRepresentationForDevice: for
images with multiple representations and fix a related bug. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33211 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
cef0eae50a
commit
31ff24d0c6
2 changed files with 26 additions and 4 deletions
|
@ -1,3 +1,12 @@
|
|||
2011-05-31 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Source/NSImage.m (-bestRepresentationForDevice): Prefer
|
||||
returning an image representation whose size matches the image
|
||||
size exactly.
|
||||
|
||||
* Source/NSImage.m (-_bestRep:withBpsMatch:): Fix test confusing
|
||||
bits per sample and bits per pixel.
|
||||
|
||||
2011-05-29 20:34-EDT Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Source/GNUmakefile: Remove NSManagedObjectContext.[hm] from compile
|
||||
|
|
|
@ -1518,9 +1518,7 @@ Fallback for backends other than Cairo. */
|
|||
max_rep = nil;
|
||||
while ((rep = [enumerator nextObject]) != nil)
|
||||
{
|
||||
int rep_bps = 0;
|
||||
if ([rep respondsToSelector: @selector(bitsPerPixel)])
|
||||
rep_bps = [(NSBitmapImageRep *)rep bitsPerPixel];
|
||||
int rep_bps = [rep bitsPerSample];
|
||||
if (rep_bps > max_bps)
|
||||
{
|
||||
max_bps = rep_bps;
|
||||
|
@ -1608,7 +1606,22 @@ Fallback for backends other than Cairo. */
|
|||
reps = [self _bestRep: reps withColorMatch: deviceDescription];
|
||||
}
|
||||
reps = [self _bestRep: reps withBpsMatch: deviceDescription];
|
||||
/* Pick an arbitrary representation if there is more than one */
|
||||
/* If we have more than one match check for a representation whose size
|
||||
* matches the image size exactly. Otherwise, arbitrarily choose the last
|
||||
* representation. */
|
||||
if ([reps count] > 1)
|
||||
{
|
||||
NSImageRep *rep;
|
||||
NSEnumerator *enumerator = [reps objectEnumerator];
|
||||
|
||||
while ((rep = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if (NSEqualSizes(_size, [rep size]) == YES)
|
||||
{
|
||||
return rep;
|
||||
}
|
||||
}
|
||||
}
|
||||
return [reps lastObject];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue