masakih

BSIconSetComposer(プロジェクト終了)

  • R/O
  • HTTP
  • SSH
  • HTTPS

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

BathyScapheのアイコンセット生成&適用ツール


ファイル情報

Rev. 6e8cc12f806a8991530cec1b7ebdddcc8223edb7
サイズ 1,931 バイト
日時 2012-06-02 23:23:37
作者 masakih
ログメッセージ

[Mod] versionを1.5.2に更新

内容

//
//  BSCSIcons.m
//  IconSetComposer
//
//  Created by Hori,Masaki on 07/03/11.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "BSCSIcons.h"

#import "IconSetComposer.h"


@implementation BSCSIcons
@synthesize image, imageFileWrapper, placeholder;
@synthesize title, identifier;

- (id)copyWithZone:(NSZone *)zone
{
	BSCSIcons *result = [[[self class] allocWithZone:zone] init];
	result.image = self.image;
	result.imageFileWrapper = self.imageFileWrapper;
	result.placeholder = self.placeholder;
	result.title = self.title;
	result.identifier = self.identifier;
	
	return result;
}

- (void)dealloc
{
	[image release];
	[imageFileWrapper release];
	[placeholder release];
	[title release];
	[identifier release];
	
	[super dealloc];
}
- (NSImage *)defaultImage
{
	return self.placeholder;
}
- (void)setDefaultImage:(NSImage *)anImage
{
	self.placeholder = anImage;
}

//- (BOOL)validateValue:(id *)ioValue forKey:(NSString *)inKey error:(NSError **)outError
//{
//	NSLog(@"Enterd########");
//	return YES;
//}

-(BOOL)validateImageFileWrapper:(id *)ioValue error:(NSError **)error
{
	if(*ioValue == nil) {
		return YES;
	}
	
	NSString *ext = [[*ioValue preferredFilename] pathExtension];
	if([IconSetComposer isAcceptImageExtension:ext]) {
		return YES;
	}
	
	if(![*ioValue isRegularFile]) {
		return NO;
	}
	
	NSData *data = [*ioValue regularFileContents];
	NSImage *aImage = [[[NSImage alloc] initWithData:data] autorelease];
	if(!aImage) {
		return NO;
	}
	
	NSData *tiffData = [aImage TIFFRepresentation];
	if(!tiffData) {
		return NO;
	}
	NSString *tiffImageName = [[*ioValue preferredFilename] lastPathComponent];
	tiffImageName = [tiffImageName stringByDeletingPathExtension];
	tiffImageName = [tiffImageName stringByAppendingPathExtension:@"tiff"];	
	
	*ioValue = [[NSFileWrapper alloc] initRegularFileWithContents:tiffData];
	[*ioValue setPreferredFilename:tiffImageName];
	
	return YES;
}
@end