* 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:
Fred Kiefer 2014-07-21 07:21:48 +00:00
parent 2af7de1105
commit abce1603c7
2 changed files with 45 additions and 48 deletions

View file

@ -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

View file

@ -56,17 +56,11 @@
return AUTORELEASE([[GormImage alloc] initWithData: aData withFileName: aName inWrapper: flag]);
}
- (id) initWithData: (NSData *)aData withFileName: (NSString *)aName inWrapper: (BOOL)flag
{
if((self = [super initWithData: aData withFileName: aName inWrapper: flag]))
- (void) _resizeSmallImage
{
NSSize originalSize;
float ratioH;
float ratioW;
ASSIGN(image, AUTORELEASE([[NSImage alloc] initWithData: aData]));
ASSIGN(smallImage, AUTORELEASE([[NSImage alloc] initWithData: aData]));
[image setName: aName];
CGFloat ratioH;
CGFloat ratioW;
originalSize = [smallImage size];
ratioW = originalSize.width / 70;
@ -84,9 +78,27 @@
[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]) != nil)
{
// FIXME: Why not make one a copy of the other?
image = [[NSImage alloc] initWithData: aData];
smallImage = [[NSImage alloc] initWithData: aData];
if (smallImage == nil)
{
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;