I'm working with large files and it seems that if I use a big enough image file my app crashes with a "[application] quit unexpectedly" modal box.
The problem is when I try to work with NSImage and get the file size for height and width dimensions. I haven't even gotten to the part where my app displays the image or allows manipulation of the image. The file I'm working with is 1.05 Gb and it is an EPS file.
I've googled to try to find an answer and I got several methods to break up a file into chunks when reading it, eg:
> NSFileHandle *fh = [NSFileHandle fileHandleForReadingAtPath:
> @"BigFile.txt"];
>
> assert(fh != NULL);
>
> unsigned len = 0;
>
> do
> {
> NSData * data = [fh availableData];
> len = [data length];
>
> printf("data len: %d offset: %lld\n", len, [fh offsetInFile]);
>
> // release the data before reading more
> // or the consequences will be quite unpleasant
>
> [data release];
>
> } while (len != 0);
but I can't figure out how to make this work with NSImage object. I don't think you can initialize an NSImage object with these chunks of data and then call size method to get the size of the image and then size.height and size.width to get the dimensions of the image.
Can anybody show me how to handle large files with NSImage?
The problem is when I try to work with NSImage and get the file size for height and width dimensions. I haven't even gotten to the part where my app displays the image or allows manipulation of the image. The file I'm working with is 1.05 Gb and it is an EPS file.
I've googled to try to find an answer and I got several methods to break up a file into chunks when reading it, eg:
> NSFileHandle *fh = [NSFileHandle fileHandleForReadingAtPath:
> @"BigFile.txt"];
>
> assert(fh != NULL);
>
> unsigned len = 0;
>
> do
> {
> NSData * data = [fh availableData];
> len = [data length];
>
> printf("data len: %d offset: %lld\n", len, [fh offsetInFile]);
>
> // release the data before reading more
> // or the consequences will be quite unpleasant
>
> [data release];
>
> } while (len != 0);
but I can't figure out how to make this work with NSImage object. I don't think you can initialize an NSImage object with these chunks of data and then call size method to get the size of the image and then size.height and size.width to get the dimensions of the image.
Can anybody show me how to handle large files with NSImage?