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
uint16* dest = (uint16*) malloc(width * height * 4 * sizeof(uint16)); | |
short* subscript = (short*) imgData; | |
for (unsigned long long i = 0; i < width * height; ++i) { | |
uint16 x = subscript[i] + 1000; | |
dest[i*4] = x; | |
} |
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
FILE *fp = fopen("/Users/dennda/Desktop/binary.buf", "wb"); | |
size_t count; | |
if(fp == NULL) { | |
printf("failed to open sample.txt\n"); | |
assert(0); | |
} | |
count = fwrite((const char*) imgData, sizeof(unsigned short), width*height, fp); | |
printf("Wrote %zu bytes. fclose(fp) %s.\n", width*height, fclose(fp) == 0 ? "succeeded" : "failed"); | |
return; |
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
FILE *fp = fopen([[[NSBundle mainBundle] pathForResource:@"binary" | |
ofType:@"buf"] | |
cStringUsingEncoding:NSUTF8StringEncoding], | |
"rb"); | |
unsigned short buffer[512*512] = {0}; /* initialized to zeroes */ | |
int i; | |
unsigned short rs; | |
if (fp == NULL) { | |
perror("Failed to open file \"myfile\""); |
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
char *dest = (char*) malloc(width * height * 4 * sizeof(char)); | |
short *subscript = (short*) imgData; | |
for (size_t i = 0; i < width * height; ++i) { | |
unsigned short x = subscript[i] + 1000; | |
dest[i*4] = x >> 8; | |
dest[i*4+1] = x; | |
dest[i*4+2] = 255; | |
dest[i*4+3] = 255; | |
} | |
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
// Storing RGBA binary buffer on disk: | |
unsigned char *dest = (unsigned char*) malloc(width * height * 4 * sizeof(unsigned char)); | |
short *subscript = (short*) imgData; | |
for (size_t i = 0; i < width * height; ++i) { | |
unsigned short x = subscript[i] + 1000; | |
dest[i*4] = x >> 8; | |
dest[i*4+1] = x; | |
dest[i*4+2] = 255; | |
dest[i*4+3] = 255; | |
} |
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
CFMutableDataRef pngdata = CreatePNGDataFromRGBA64Raster((void*) dest, width, height, width * 4); | |
NSData *data = (__bridge NSData*) pngdata; | |
NSURL *url = [NSURL URLWithString:@"/Users/dennda/Desktop/dicomraster.png"]; | |
[data writeToURL:url atomically:YES]; |
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
- (IBAction)selectDataset:(id)sender { | |
NSLog(@"Presenting picker"); | |
NSArray *files = [self presentPicker]; | |
NSLog(@"User picked %lu files.", files.count); | |
self.progressBar.maxValue = files.count; | |
// For every .dcm file, create a thread and convert it to a PVRTC texture | |
dispatch_queue_t queue = dispatch_queue_create("org.denter.DICOM2PVR", NULL); | |
for (NSString *fn in files) { | |
dispatch_async(queue, ^{ |
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
- (void)taskTerminated:(NSNotification *)aNotification { | |
[self.progressBar incrementBy:1.]; | |
spawned_tasks -= 1; | |
if (_unprocessed_files.count > 0) | |
[self spawnCompressor]; | |
} | |
- (void) spawnCompressor { | |
NSString *executable = [[NSBundle mainBundle] pathForAuxiliaryExecutable:@"compress"]; |
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
$ sudo easy_install docutils | |
Traceback (most recent call last): | |
File "/usr/local/bin/easy_install", line 5, in <module> | |
from pkg_resources import load_entry_point | |
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2607, in <module> | |
parse_requirements(__requires__), Environment() | |
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve | |
raise DistributionNotFound(req) # XXX put more info here | |
pkg_resources.DistributionNotFound: setuptools==0.6c12dev-r88846 |
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
// old: | |
- (void)taskTerminated:(NSNotification *)task { | |
} | |
// versus new: | |
- (void)taskTerminated:(NSNotification *)tasknot { | |
NSTask *task = tasknot.object; | |
.... | |
} |