mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 18:11:06 +00:00
* Source/NSScreen.m: Use -userSpaceScaleFactor to calculate
NSDeviceResolution * Source/NSImage.m: Implement -_bestRep:withResolutionMatch: * Images/common_Dimple.tiff: * Images/common_3DArrowRight.tiff: Add to these images a second 'page' at 4x the original resolution which I drew. If you use GSScaleFactor > 1 then the high resolution version of these images should be used. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@32975 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2873a337e6
commit
ce051d9bd8
5 changed files with 84 additions and 27 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2011-05-03 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/NSScreen.m: Use -userSpaceScaleFactor to calculate
|
||||
NSDeviceResolution
|
||||
* Source/NSImage.m: Implement -_bestRep:withResolutionMatch:
|
||||
* Images/common_Dimple.tiff:
|
||||
* Images/common_3DArrowRight.tiff: Add to these images
|
||||
a second 'page' at 4x the original resolution which I drew.
|
||||
|
||||
If you use GSScaleFactor > 1 then the high resolution version
|
||||
of these images should be used.
|
||||
|
||||
2011-05-01 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Images: Ensure all images have their DPI metadata set to 72.
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1421,35 +1421,83 @@ Fallback for backends other than Cairo. */
|
|||
return breps;
|
||||
}
|
||||
|
||||
/* Find reps that match the resolution of the device or return the rep
|
||||
that has the highest resolution */
|
||||
/* Find reps that match the resolution of the device or return the
|
||||
vector reps or the reps that have the highest resolution */
|
||||
- (NSMutableArray *) _bestRep: (NSArray *)reps
|
||||
withResolutionMatch: (NSDictionary*)deviceDescription
|
||||
{
|
||||
NSImageRep* rep;
|
||||
NSMutableArray *breps;
|
||||
NSEnumerator *enumerator = [reps objectEnumerator];
|
||||
|
||||
/*
|
||||
NSSize dres;
|
||||
NSValue *resolution = [deviceDescription objectForKey: NSDeviceResolution];
|
||||
NSMutableArray *breps = [NSMutableArray array];
|
||||
|
||||
if (resolution)
|
||||
dres = [resolution sizeValue];
|
||||
else
|
||||
dres = NSMakeSize(0, 0);
|
||||
*/
|
||||
/* Look for exact resolution matches */
|
||||
|
||||
breps = [NSMutableArray array];
|
||||
while ((rep = [enumerator nextObject]) != nil)
|
||||
if (nil != resolution)
|
||||
{
|
||||
/* FIXME: Not sure about checking resolution */
|
||||
[breps addObject: rep];
|
||||
NSSize dres = [resolution sizeValue];
|
||||
|
||||
NSImageRep *rep;
|
||||
NSEnumerator *enumerator = [reps objectEnumerator];
|
||||
|
||||
while ((rep = [enumerator nextObject]) != nil)
|
||||
{
|
||||
NSSize size = [rep size];
|
||||
NSSize res = NSMakeSize(72.0 * [rep pixelsWide] / size.width,
|
||||
72.0 * [rep pixelsHigh] / size.height);
|
||||
if (NSEqualSizes(res, dres))
|
||||
{
|
||||
[breps addObject: rep];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If no exact matches found, look for vector reps */
|
||||
|
||||
/* If there are no matches, pass all the reps */
|
||||
if ([breps count] == 0)
|
||||
return (NSMutableArray *)reps;
|
||||
{
|
||||
NSImageRep *rep;
|
||||
NSEnumerator *enumerator = [reps objectEnumerator];
|
||||
while ((rep = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if ([rep pixelsWide] == NSImageRepMatchesDevice &&
|
||||
[rep pixelsHigh] == NSImageRepMatchesDevice)
|
||||
{
|
||||
[breps addObject: rep];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Otherwise, use the largest bitmaps */
|
||||
|
||||
if ([breps count] == 0)
|
||||
{
|
||||
NSSize maxPixelSize = NSMakeSize(0,0);
|
||||
NSImageRep *rep;
|
||||
NSEnumerator *enumerator = [reps objectEnumerator];
|
||||
while ((rep = [enumerator nextObject]) != nil)
|
||||
{
|
||||
NSSize pixelSize = NSMakeSize([rep pixelsWide], [rep pixelsHigh]);
|
||||
if (pixelSize.width > maxPixelSize.width &&
|
||||
pixelSize.height > maxPixelSize.height)
|
||||
{
|
||||
maxPixelSize = pixelSize;
|
||||
}
|
||||
}
|
||||
|
||||
enumerator = [reps objectEnumerator];
|
||||
while ((rep = [enumerator nextObject]) != nil)
|
||||
{
|
||||
NSSize pixelSize = NSMakeSize([rep pixelsWide], [rep pixelsHigh]);
|
||||
if (NSEqualSizes(pixelSize, maxPixelSize))
|
||||
{
|
||||
[breps addObject: rep];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ([breps count] == 0)
|
||||
{
|
||||
[breps setArray: reps];
|
||||
}
|
||||
return breps;
|
||||
}
|
||||
|
||||
|
|
|
@ -274,7 +274,7 @@ static NSMutableArray *screenArray = nil;
|
|||
int bps = 0;
|
||||
NSSize screenResolution;
|
||||
NSString *colorSpaceName = nil;
|
||||
GSDisplayServer *srv;
|
||||
CGFloat scaleFactor;
|
||||
|
||||
/*
|
||||
* This method generates a dictionary from the
|
||||
|
@ -294,13 +294,10 @@ static NSMutableArray *screenArray = nil;
|
|||
forKey: NSDeviceSize];
|
||||
|
||||
// Add the NSDeviceResolution dictionary item
|
||||
srv = GSCurrentServer();
|
||||
if (srv != nil)
|
||||
{
|
||||
screenResolution = [srv resolutionForScreen: _screenNumber];
|
||||
[devDesc setObject: [NSValue valueWithSize: screenResolution]
|
||||
forKey: NSDeviceResolution];
|
||||
}
|
||||
scaleFactor = [self userSpaceScaleFactor];
|
||||
screenResolution = NSMakeSize(72.0 * scaleFactor, 72.0 * scaleFactor);
|
||||
[devDesc setObject: [NSValue valueWithSize: screenResolution]
|
||||
forKey: NSDeviceResolution];
|
||||
|
||||
// Add the bits per sample entry
|
||||
bps = NSBitsPerSampleFromDepth(_depth);
|
||||
|
|
Loading…
Reference in a new issue