I have a structure that includes a pointer to the data set, which is 16-bit grayscale image in this case. I want to convert this data into an NSImage so that I can display it and then save it as a .tiff file. The route from the manual appears something like this:
create myNSImData from image (frame-> gt; which is an indicator) NSImage * TestImage = [[NSImage alloc] initWithData: myNSImData]; (Display test image, save it, whatever) [test image release]; How I am losing about creating an NSData object and assuring that it has an array of 16-bit data. Restore attempts give the warnings and give no data. I only increase the points, one byte at a time frame-> The data could move from the object into the object, but I do not understand how to communicate the array structure in the data object. any idea? Thanks
More suggestions using your suggestion I get this data one. To change the TIF file in the following way:
For (uint32 row = 0; line & lt; MaxHeight; line ++) {for (uint32 column = 0; column & lt; MaxWidth; Column ++) {tempData = (uint8_t) * Frame- & gt; Image; // first byte * frame-> Image ++; Buf [2 * column + 1] = (unsigned char) tempData; TempData = (uint8_t) * frame- & gt; Image; // second byte * frame-> Image ++; Buf [2 * column] = (unsigned char) tempData; } TIFFWriteScanline (Tiffel, Buff, Row, 0); } With this generated TIF file, I can create an NSImage and display it:
NSImage * TestImage = [[[[ NSImage alloc] initWithContentsOfFile: InFilePath] autorelease]; [View window set image: test image]; My question is created now - can I create an NSData object that I can display in the same way? I have tried the following (the height of the product image is * width):
NSData * ReadImage = [[NSData alloc] initWithBytes: frame-> Image Length: 2 * Products] Autoreshoe]; NSImage * NewImage = [[NSImage alloc] initWithData: ReadImage] autorelease]; NSSize new size; NewSize.height = MaxHit; // image height newSize.width = MaxWidth; // Image width [New image set: Size: New shape]; [View window set image: new image]; When I try this, nothing shows that I have also tried to create an array of UIT 16_T, which has data, and the pointer on it - again, some Does not show any ideas? Like I have to tell NSDTO that I'm using 2 bytes per pixel, or something like that? Thanks Monty Wood
create a block to create an NSData object For an indicator, you should use one of three ways, that starts with creating an autorelated NSData object, or update: I think if you want to create a NSImage directly from NSData then the data needs to include the appropriate header / magic number If you can see what the representation is, you should see the raw image data and the Coco drawing guide.
Comments
Post a Comment