Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added 'Image To Data' patch to convert an image to bytes. [#2170]
- Loading branch information
1 parent
b3be0cb
commit 2d99dd8
Showing
6 changed files
with
170 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,15 @@ | |||
@interface DTImageToDataPatch : QCPatch | |||
{ | |||
QCImagePort *inputImage; | |||
QCIndexPort *inputImageFileType; | |||
QCVirtualPort *outputRawData; | |||
} | |||
|
|||
+(BOOL)isSafe; | |||
+(BOOL)allowsSubpatchesWithIdentifier:(id)identifier; | |||
+(QCPatchExecutionMode)executionModeWithIdentifier:(id)identifier; | |||
+(QCPatchTimeMode)timeModeWithIdentifier:(id)identifier; | |||
-(id)initWithIdentifier:(id)identifier; | |||
-(BOOL)execute:(QCOpenGLContext*)context time:(double)time arguments:(NSDictionary*)arguments; | |||
|
|||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,53 @@ | |||
#import "DTImageToDataPatch.h" | |||
|
|||
@implementation DTImageToDataPatch | |||
|
|||
+(BOOL)isSafe | |||
{ | |||
return NO; | |||
} | |||
|
|||
+(BOOL)allowsSubpatchesWithIdentifier:(id)identifier | |||
{ | |||
return NO; | |||
} | |||
|
|||
+(QCPatchExecutionMode)executionModeWithIdentifier:(id)identifier | |||
{ | |||
return kQCPatchExecutionModeProcessor; | |||
} | |||
|
|||
+(QCPatchTimeMode)timeModeWithIdentifier:(id)identifier | |||
{ | |||
return kQCPatchTimeModeNone; | |||
} | |||
|
|||
-(id)initWithIdentifier:(id)identifier | |||
{ | |||
if(self = [super initWithIdentifier:identifier]) | |||
{ | |||
[[self userInfo] setObject:@"Kineme Image To Data" forKey:@"name"]; | |||
|
|||
[inputImageFileType setMaxIndexValue:NSJPEG2000FileType]; | |||
[inputImageFileType setIndexValue:NSPNGFileType]; | |||
} | |||
return self; | |||
} | |||
|
|||
-(BOOL)execute:(QCOpenGLContext*)context time:(double)time arguments:(NSDictionary*)arguments | |||
{ | |||
if ([inputImage wasUpdated] || [inputImageFileType wasUpdated]) | |||
{ | |||
NSBitmapImageFileType imageFileType = [inputImageFileType indexValue]; | |||
NSImage *image = [inputImage value]; | |||
NSArray *representations = [image representations]; | |||
NSData *data = [NSBitmapImageRep representationOfImageRepsInArray:representations | |||
usingType:imageFileType | |||
properties:nil]; | |||
[outputRawData setRawValue:data]; | |||
} | |||
|
|||
return YES; | |||
} | |||
|
|||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,57 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |||
<plist version="1.0"> | |||
<dict> | |||
<key>nodeAttributes</key> | |||
<dict> | |||
<key>name</key> | |||
<string>Image To Data</string> | |||
<key>categories</key> | |||
<array> | |||
<string>Kineme DataTools</string> | |||
</array> | |||
<key>copyright</key> | |||
<string>Copyright 2011 Kosada Incorporated. All rights reserved.</string> | |||
<key>description</key> | |||
<string>This patch converts an image to raw data bytes. | |||
|
|||
http://kineme.net/</string> | |||
</dict> | |||
<key>inputAttributes</key> | |||
<dict> | |||
<key>inputImage</key> | |||
<dict> | |||
<key>name</key> | |||
<string>Image</string> | |||
<key>description</key> | |||
<string>The image to convert</string> | |||
</dict> | |||
<key>inputImageFileType</key> | |||
<dict> | |||
<key>name</key> | |||
<string>Image Representation</string> | |||
<key>description</key> | |||
<string>The image representation to use when converting to bytes</string> | |||
<key>menu</key> | |||
<array> | |||
<string>TIFF</string> | |||
<string>BMP</string> | |||
<string>GIF</string> | |||
<string>JPEG</string> | |||
<string>PNG</string> | |||
<string>JPEG2000</string> | |||
</array> | |||
</dict> | |||
</dict> | |||
<key>outputAttributes</key> | |||
<dict> | |||
<key>outputRawData</key> | |||
<dict> | |||
<key>name</key> | |||
<string>Raw Data</string> | |||
<key>description</key> | |||
<string>The bytes of the image</string> | |||
</dict> | |||
</dict> | |||
</dict> | |||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters