mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 08:41:00 +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
7afbe7b2bd
commit
99bd5d4243
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>
|
2011-05-01 Eric Wasylishen <ewasylishen@gmail.com>
|
||||||
|
|
||||||
* Images: Ensure all images have their DPI metadata set to 72.
|
* 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;
|
return breps;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find reps that match the resolution of the device or return the rep
|
/* Find reps that match the resolution of the device or return the
|
||||||
that has the highest resolution */
|
vector reps or the reps that have the highest resolution */
|
||||||
- (NSMutableArray *) _bestRep: (NSArray *)reps
|
- (NSMutableArray *) _bestRep: (NSArray *)reps
|
||||||
withResolutionMatch: (NSDictionary*)deviceDescription
|
withResolutionMatch: (NSDictionary*)deviceDescription
|
||||||
{
|
{
|
||||||
|
NSValue *resolution = [deviceDescription objectForKey: NSDeviceResolution];
|
||||||
|
NSMutableArray *breps = [NSMutableArray array];
|
||||||
|
|
||||||
|
/* Look for exact resolution matches */
|
||||||
|
|
||||||
|
if (nil != resolution)
|
||||||
|
{
|
||||||
|
NSSize dres = [resolution sizeValue];
|
||||||
|
|
||||||
NSImageRep *rep;
|
NSImageRep *rep;
|
||||||
NSMutableArray *breps;
|
|
||||||
NSEnumerator *enumerator = [reps objectEnumerator];
|
NSEnumerator *enumerator = [reps objectEnumerator];
|
||||||
|
|
||||||
/*
|
|
||||||
NSSize dres;
|
|
||||||
NSValue *resolution = [deviceDescription objectForKey: NSDeviceResolution];
|
|
||||||
|
|
||||||
if (resolution)
|
|
||||||
dres = [resolution sizeValue];
|
|
||||||
else
|
|
||||||
dres = NSMakeSize(0, 0);
|
|
||||||
*/
|
|
||||||
|
|
||||||
breps = [NSMutableArray array];
|
|
||||||
while ((rep = [enumerator nextObject]) != nil)
|
while ((rep = [enumerator nextObject]) != nil)
|
||||||
{
|
{
|
||||||
/* FIXME: Not sure about checking resolution */
|
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];
|
[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)
|
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;
|
return breps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -274,7 +274,7 @@ static NSMutableArray *screenArray = nil;
|
||||||
int bps = 0;
|
int bps = 0;
|
||||||
NSSize screenResolution;
|
NSSize screenResolution;
|
||||||
NSString *colorSpaceName = nil;
|
NSString *colorSpaceName = nil;
|
||||||
GSDisplayServer *srv;
|
CGFloat scaleFactor;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This method generates a dictionary from the
|
* This method generates a dictionary from the
|
||||||
|
@ -294,13 +294,10 @@ static NSMutableArray *screenArray = nil;
|
||||||
forKey: NSDeviceSize];
|
forKey: NSDeviceSize];
|
||||||
|
|
||||||
// Add the NSDeviceResolution dictionary item
|
// Add the NSDeviceResolution dictionary item
|
||||||
srv = GSCurrentServer();
|
scaleFactor = [self userSpaceScaleFactor];
|
||||||
if (srv != nil)
|
screenResolution = NSMakeSize(72.0 * scaleFactor, 72.0 * scaleFactor);
|
||||||
{
|
|
||||||
screenResolution = [srv resolutionForScreen: _screenNumber];
|
|
||||||
[devDesc setObject: [NSValue valueWithSize: screenResolution]
|
[devDesc setObject: [NSValue valueWithSize: screenResolution]
|
||||||
forKey: NSDeviceResolution];
|
forKey: NSDeviceResolution];
|
||||||
}
|
|
||||||
|
|
||||||
// Add the bits per sample entry
|
// Add the bits per sample entry
|
||||||
bps = NSBitsPerSampleFromDepth(_depth);
|
bps = NSBitsPerSampleFromDepth(_depth);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue