mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-23 11:41:05 +00:00
* GormCore/GormImage.m: Fix the init issue for the second
method as well. Small cleanup. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@38002 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2af7de1105
commit
abce1603c7
2 changed files with 45 additions and 48 deletions
|
@ -1,3 +1,8 @@
|
|||
2014-07-21 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* GormCore/GormImage.m: Fix the init issue for the second
|
||||
method as well. Small cleanup.
|
||||
|
||||
2014-05-31 10:58-EDT Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* GormCore/GormDocumentController.h: add declaration of
|
||||
|
|
|
@ -56,37 +56,49 @@
|
|||
return AUTORELEASE([[GormImage alloc] initWithData: aData withFileName: aName inWrapper: flag]);
|
||||
}
|
||||
|
||||
- (void) _resizeSmallImage
|
||||
{
|
||||
NSSize originalSize;
|
||||
CGFloat ratioH;
|
||||
CGFloat ratioW;
|
||||
|
||||
originalSize = [smallImage size];
|
||||
ratioW = originalSize.width / 70;
|
||||
ratioH = originalSize.height / 55;
|
||||
|
||||
if (ratioH > 1 || ratioW > 1)
|
||||
{
|
||||
[smallImage setScalesWhenResized: YES];
|
||||
if (ratioH > ratioW)
|
||||
{
|
||||
[smallImage setSize: NSMakeSize(originalSize.width / ratioH, 55)];
|
||||
}
|
||||
else
|
||||
{
|
||||
[smallImage setSize: NSMakeSize(70, originalSize.height / ratioW)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithData: (NSData *)aData withFileName: (NSString *)aName inWrapper: (BOOL)flag
|
||||
{
|
||||
if((self = [super initWithData: aData withFileName: aName inWrapper: flag]))
|
||||
if ((self = [super initWithData: aData withFileName: aName inWrapper: flag]) != nil)
|
||||
{
|
||||
NSSize originalSize;
|
||||
float ratioH;
|
||||
float ratioW;
|
||||
// FIXME: Why not make one a copy of the other?
|
||||
image = [[NSImage alloc] initWithData: aData];
|
||||
smallImage = [[NSImage alloc] initWithData: aData];
|
||||
|
||||
ASSIGN(image, AUTORELEASE([[NSImage alloc] initWithData: aData]));
|
||||
ASSIGN(smallImage, AUTORELEASE([[NSImage alloc] initWithData: aData]));
|
||||
[image setName: aName];
|
||||
|
||||
originalSize = [smallImage size];
|
||||
ratioW = originalSize.width / 70;
|
||||
ratioH = originalSize.height / 55;
|
||||
|
||||
if (ratioH > 1 || ratioW > 1)
|
||||
if (smallImage == nil)
|
||||
{
|
||||
[smallImage setScalesWhenResized: YES];
|
||||
if (ratioH > ratioW)
|
||||
{
|
||||
[smallImage setSize: NSMakeSize(originalSize.width / ratioH, 55)];
|
||||
}
|
||||
else
|
||||
{
|
||||
[smallImage setSize: NSMakeSize(70, originalSize.height / ratioW)];
|
||||
}
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
[image setName: aName];
|
||||
// FIXME: Not needed
|
||||
[image setArchiveByName: NO];
|
||||
[smallImage setArchiveByName: NO];
|
||||
[self _resizeSmallImage];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -95,15 +107,10 @@
|
|||
path: (NSString *)aPath
|
||||
inWrapper: (BOOL)flag
|
||||
{
|
||||
if((self = [super initWithName: aName path: aPath inWrapper: flag]))
|
||||
if ((self = [super initWithName: aName path: aPath inWrapper: flag]) != nil)
|
||||
{
|
||||
NSSize originalSize;
|
||||
float ratioH;
|
||||
float ratioW;
|
||||
|
||||
ASSIGN(image, AUTORELEASE([[NSImage alloc] initByReferencingFile: aPath]));
|
||||
ASSIGN(smallImage, AUTORELEASE([[NSImage alloc] initWithContentsOfFile: aPath]));
|
||||
[image setName: aName];
|
||||
image = [[NSImage alloc] initByReferencingFile: aPath];
|
||||
smallImage = [[NSImage alloc] initWithContentsOfFile: aPath];
|
||||
|
||||
if (smallImage == nil)
|
||||
{
|
||||
|
@ -111,25 +118,10 @@
|
|||
return nil;
|
||||
}
|
||||
|
||||
originalSize = [smallImage size];
|
||||
ratioW = originalSize.width / 70;
|
||||
ratioH = originalSize.height / 55;
|
||||
|
||||
if (ratioH > 1 || ratioW > 1)
|
||||
{
|
||||
[smallImage setScalesWhenResized: YES];
|
||||
if (ratioH > ratioW)
|
||||
{
|
||||
[smallImage setSize: NSMakeSize(originalSize.width / ratioH, 55)];
|
||||
}
|
||||
else
|
||||
{
|
||||
[smallImage setSize: NSMakeSize(70, originalSize.height / ratioW)];
|
||||
}
|
||||
}
|
||||
|
||||
[image setName: aName];
|
||||
[image setArchiveByName: NO];
|
||||
[smallImage setArchiveByName: NO];
|
||||
[self _resizeSmallImage];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
|
Loading…
Reference in a new issue