Skip to content
Browse files

potential fix for issue #1

  • Loading branch information...
1 parent cfa3350 commit be5bf6ae45bfeb26d9502916e3618fc72cd05be3 @kgn committed Jun 23, 2011
Showing with 77 additions and 15 deletions.
  1. +12 −0 EyeTunes.xcodeproj/project.pbxproj
  2. +2 −15 Source/ETTrack.m
  3. +15 −0 Source/NSImage+PICT.h
  4. +48 −0 Source/NSImage+PICT.m
View
12 EyeTunes.xcodeproj/project.pbxproj
@@ -51,6 +51,9 @@
638ADA3F1325160700B02DFB /* NSNumber+ETPlaylistNameSorting.m in Sources */ = {isa = PBXBuildFile; fileRef = DDEBCD330E8D245000219086 /* NSNumber+ETPlaylistNameSorting.m */; };
735028C813B339A700DD08C4 /* NSString+LongLongValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 735028C613B339A700DD08C4 /* NSString+LongLongValue.h */; };
735028C913B339A700DD08C4 /* NSString+LongLongValue.m in Sources */ = {isa = PBXBuildFile; fileRef = 735028C713B339A700DD08C4 /* NSString+LongLongValue.m */; };
+ 7395802513B3514C0015C726 /* NSImage+PICT.h in Headers */ = {isa = PBXBuildFile; fileRef = 7395802313B3514C0015C726 /* NSImage+PICT.h */; };
+ 7395802613B3514C0015C726 /* NSImage+PICT.m in Sources */ = {isa = PBXBuildFile; fileRef = 7395802413B3514C0015C726 /* NSImage+PICT.m */; };
+ 7395802813B351CD0015C726 /* QuickTime.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7395802713B351CD0015C726 /* QuickTime.framework */; };
DD233EB70E66FD45004B210F /* ETUserPlaylistEnumerator.m in Sources */ = {isa = PBXBuildFile; fileRef = DD233EAB0E66FCC4004B210F /* ETUserPlaylistEnumerator.m */; };
DD233EB80E66FD45004B210F /* ETUserPlaylistEnumerator.h in Headers */ = {isa = PBXBuildFile; fileRef = DD233EAA0E66FCC4004B210F /* ETUserPlaylistEnumerator.h */; settings = {ATTRIBUTES = (Public, ); }; };
DDB3AF3D0EC4A147003C7FE6 /* ETRootUserPlaylist.m in Sources */ = {isa = PBXBuildFile; fileRef = DD2AB89A0E97A88800178457 /* ETRootUserPlaylist.m */; };
@@ -117,6 +120,9 @@
32DBCF5E0370ADEE00C91783 /* EyeTunes_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EyeTunes_Prefix.pch; sourceTree = "<group>"; };
735028C613B339A700DD08C4 /* NSString+LongLongValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+LongLongValue.h"; sourceTree = "<group>"; };
735028C713B339A700DD08C4 /* NSString+LongLongValue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+LongLongValue.m"; sourceTree = "<group>"; };
+ 7395802313B3514C0015C726 /* NSImage+PICT.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSImage+PICT.h"; sourceTree = "<group>"; };
+ 7395802413B3514C0015C726 /* NSImage+PICT.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSImage+PICT.m"; sourceTree = "<group>"; };
+ 7395802713B351CD0015C726 /* QuickTime.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickTime.framework; path = ../../../../../System/Library/Frameworks/QuickTime.framework; sourceTree = "<group>"; };
8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
8DC2EF5B0486A6940098B216 /* EyeTunes.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = EyeTunes.framework; sourceTree = BUILT_PRODUCTS_DIR; };
DD233EAA0E66FCC4004B210F /* ETUserPlaylistEnumerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ETUserPlaylistEnumerator.h; sourceTree = "<group>"; };
@@ -154,6 +160,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ 7395802813B351CD0015C726 /* QuickTime.framework in Frameworks */,
030BFB0B098D01BE00D68616 /* Foundation.framework in Frameworks */,
031B48AB088444F60086F24B /* ApplicationServices.framework in Frameworks */,
030BFB92098D517A00D68616 /* AppKit.framework in Frameworks */,
@@ -205,6 +212,7 @@
0867D691FE84028FC02AAC07 /* EyeTunes */ = {
isa = PBXGroup;
children = (
+ 7395802713B351CD0015C726 /* QuickTime.framework */,
039620900C0DE6E500786326 /* Examples */,
08FB77AEFE84172EC02AAC07 /* Classes */,
32C88DFF0371C24200C91783 /* Other Sources */,
@@ -263,6 +271,8 @@
735028C713B339A700DD08C4 /* NSString+LongLongValue.m */,
DDEBCD320E8D245000219086 /* NSNumber+ETPlaylistNameSorting.h */,
DDEBCD330E8D245000219086 /* NSNumber+ETPlaylistNameSorting.m */,
+ 7395802313B3514C0015C726 /* NSImage+PICT.h */,
+ 7395802413B3514C0015C726 /* NSImage+PICT.m */,
);
name = Classes;
path = Source;
@@ -298,6 +308,7 @@
DDEBCC910E8D1EF700219086 /* ETPlaylistCache.h in Headers */,
DDB3AF3E0EC4A148003C7FE6 /* ETRootUserPlaylist.h in Headers */,
735028C813B339A700DD08C4 /* NSString+LongLongValue.h in Headers */,
+ 7395802513B3514C0015C726 /* NSImage+PICT.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -451,6 +462,7 @@
DD233EB70E66FD45004B210F /* ETUserPlaylistEnumerator.m in Sources */,
DDEBCD360E8D255600219086 /* NSNumber+ETPlaylistNameSorting.m in Sources */,
735028C913B339A700DD08C4 /* NSString+LongLongValue.m in Sources */,
+ 7395802613B3514C0015C726 /* NSImage+PICT.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
17 Source/ETTrack.m
@@ -40,6 +40,7 @@ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
#import "ETTrack.h"
#import "NSString+LongLongValue.h"
+#import "NSImage+PICT.h"
#import "ETDebug.h"
@@ -76,23 +77,9 @@ - (BOOL)setArtwork:(NSImage *)artwork atIndex:(int)index
{
AEDesc pictDesc;
OSErr err;
- NSPasteboard *pboard = nil;
- NSData *tiffData;
if (artwork != nil) {
- tiffData = [artwork TIFFRepresentation];
- if (tiffData == nil) {
- ETLog(@"Unable to convert NSImage to TIFF");
- return NO;
- }
-
- // force NSPasteboard to do conversion for us?
- pboard = [NSPasteboard pasteboardWithName:@"EyeTunes"];
- [pboard declareTypes:[NSArray arrayWithObject:NSTIFFPboardType] owner:nil];
- [pboard setData:tiffData forType:NSTIFFPboardType];
- [pboard types]; // need this for some reason to force pboard to present more datatypes
- NSData *pictData = [pboard dataForType:NSPICTPboardType];
- [pboard releaseGlobally];
+ NSData *pictData = [artwork pictRepresentation];
if ([pictData length] < 512) {
ETLog(@"Unable to convert to PICT");
View
15 Source/NSImage+PICT.h
@@ -0,0 +1,15 @@
+//
+// NSImage+PICT.h
+// EyeTunes
+//
+// Created by David Keegan on 6/23/11.
+// Copyright 2011 InScopeApps {+}. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface NSImage (PICT)
+
+- (NSData*) pictRepresentation;
+
+@end
View
48 Source/NSImage+PICT.m
@@ -0,0 +1,48 @@
+//
+// NSImage+PICT.m
+// EyeTunes
+//
+// Created by David Keegan on 6/23/11.
+// Copyright 2011 InScopeApps {+}. All rights reserved.
+//
+// From: http://www.cocoabuilder.com/archive/cocoa/82390-nsimage-to-pict.html
+//
+
+#import <QuickTime/QuickTime.h>
+#import "NSImage+PICT.h"
+
+@implementation NSImage (PICT)
+
+- (NSData*) pictRepresentation
+{
+ MovieImportComponent importer;
+
+ if (OpenADefaultComponent(GraphicsImporterComponentType,
+ kQTFileTypeTIFF, &importer) != noErr)
+ {
+ CloseComponent(importer);
+ return nil;
+ }
+
+ Handle imageHandle;
+ NSData *imageData = [self TIFFRepresentation];
+ long int dataSize = [imageData length];
+ (void)PtrToHand([imageData bytes], &imageHandle, dataSize);
+
+ OSErr err = GraphicsImportSetDataHandle(importer, imageHandle);
+ if (err != noErr)
+ {
+ return nil;
+ }
+
+ PicHandle resultPicHandle = (PicHandle)NewHandleClear(20);
+ err = GraphicsImportGetAsPicture(importer, &resultPicHandle) ;
+
+ NSData *returnValue = [NSData dataWithBytes:*resultPicHandle
+ length:(int)GetHandleSize((Handle)resultPicHandle)];
+ DisposeHandle((Handle)resultPicHandle);
+
+ return returnValue;
+}
+
+@end

0 comments on commit be5bf6a

Please sign in to comment.
Something went wrong with that request. Please try again.