/
XeeLosslessSaver.m
65 lines (51 loc) · 1.94 KB
/
XeeLosslessSaver.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#import "XeeLosslessSaver.h"
@implementation XeeLosslessSaver
+(BOOL)canSaveImage:(XeeImage *)img
{
return [img losslessSaveFlags]&XeeCanSaveLosslesslyFlag?YES:NO;
}
-(id)initWithImage:(XeeImage *)img
{
if(self=[super initWithImage:img])
{
int flags=[image losslessSaveFlags];
untransformable=nil;
cropping=nil;
if(flags&XeeUntransformableBlocksCanBeRetainedFlag)
untransformable=[XeeSLPopUp popUpWithTitle:
NSLocalizedString(@"Untransformable edge blocks:",@"Title for the popup for selecting the action for untransformable blocks when saving losslessly")
defaultValue:0 contents:
NSLocalizedString(@"Keep",@"Option to keep untranslatable edge blocks"),
NSLocalizedString(@"Remove",@"Option to remove untranslatable edge blocks"),
nil];
if(flags&XeeCroppingIsInexactFlag)
cropping=[XeeSLPopUp popUpWithTitle:
NSLocalizedString(@"Cropping:",@"Title for the popup for the action when cropping in inexact when saving losslessly")
defaultValue:0 contents:
NSLocalizedString(@"Expand",@"Option to expand the cropping area when saving losslessly"),
NSLocalizedString(@"Trim",@"Option to trim the cropping area when saving losslessly"),
nil];
if(untransformable&&cropping) [self setControl:[XeeSLGroup groupWithControls:untransformable,cropping,nil]];
else if(untransformable) [self setControl:untransformable];
else if(cropping) [self setControl:cropping];
}
return self;
}
-(NSString *)format
{
return [NSString stringWithFormat:
NSLocalizedString(@"%@, Without Recompressing",@"Save panel format name for lossless saving (%@ is the format name, currently always JPEG)"),
[image losslessFormat]];
}
-(NSString *)extension
{
return [image losslessExtension];
}
-(BOOL)save:(NSString *)filename
{
int flags=0;
if(untransformable&&[untransformable value]==0) flags|=XeeRetainUntransformableBlocksFlag;
if(cropping&&[cropping value]==1) flags|=XeeTrimCroppingFlag;
return [image losslessSaveTo:filename flags:flags];
}
@end