문제

Mac에서 Photoshop 플러그인을 구현하고 있으며 Cocoa를 사용하여 수행하고 있습니다. 지금까지 확인했지만 다음 단계는 플러그인 창의 일부로 "미리보기"이미지를 제공하는 것입니다. 나는 N00B OBJ-C 프로그래머입니다. 실제로 도움이되지 않습니다 :-)

지금까지 나는 다음과 같은 것을 가지고 있습니다.

int dataSize = gFilterRecord->bigDocumentData->wholeSize32.v *
               gFilterRecord->bigDocumentData->wholeSize32.h *
               gFilterRecord->planes; 

NSData *inData = [[NSData alloc] initWithBytesNoCopy:gFilterRecord->inData length:dataSize freeWhenDone:NO];
NSLog(@"LoadImageFromSDK : Data created");
NSImage *imageTmp = [[NSImage alloc] initWithData:inData];
NSLog(@"LoadImageFromSDK : Image created");

//Save to PNG file as a test of this image creation
[[imageTmp TIFFRepresentation] writeToFile:@"/tmp/imageTmp.tif" atomically:YES];
NSLog(@"LoadImageFromSDK : Wrote image to disk");

현재, 그것은 끔찍하게 충돌합니다.
09/07/22 10:23:32 AM Adobe Photoshop Elements [46628] *** nscopymemorypages (0x0, 0x245f4000, 2265088) 실패

아마도 Indata의 크기를 잘못 계산하고있을 것입니다. 돕다?

또한 NSIMAGE가 해당 이미지 데이터 블로브를 올바르게 해석 할 수 있을까요? 아니면 포기하고 픽셀 바이 픽셀 맵핑을 nsimage에 맵핑해야합니까?

도움이 되었습니까?

해결책

좋아, 그것은 내가 예상했던 것보다 더 고통 스러웠다. 또한이 글을 게시 한 Nvidia에 대한 Kudos PDF 이것은 실제 SDK 문서보다 Photoshop SDK 필터 레코드에 대한 더 나은 설명입니다.

이 코드는 실제로 Indata를 읽고 디버깅 목적으로 샘플 TIF 파일 외에도 사용 가능한 NSIMAGE (사용중인 작업을 파악하고 제거 할 수있는 많은 로깅)를 생성합니다.

NSLog(@"Entering LoadImageFromSDK");

unsigned char *bitmapPlanes[4];    
bitmapPlanes[0] = (unsigned char *) (gFilterRecord->inData);

NSLog(@"Params to create bitmap");
NSLog(@"pixelsWide = %d", gFilterRecord->bigDocumentData->imageSize32.h );
NSLog(@"pixelsHigh = %d", gFilterRecord->bigDocumentData->imageSize32.v );
NSLog(@"bitsPerSample = %d", gFilterRecord->depth );
NSLog(@"samplesPerPixel = %d", gFilterRecord->planes );
NSLog(@"hasAlpha = %d", NO );
NSLog(@"isPlanar = %d", NO );
NSLog(@"colorSpaceName = %@", mapImageModeToColorSpace(gFilterRecord->imageMode) );
NSLog(@"bytesPerRow = %d", gFilterRecord->inRowBytes );
NSLog(@"bitsPerPixel = %d", gFilterRecord->depth*gFilterRecord->planes );    

NSBitmapImageRep *bitmapTmp = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:bitmapPlanes
                                                                      pixelsWide:gFilterRecord->bigDocumentData->imageSize32.h
                                                                      pixelsHigh:gFilterRecord->bigDocumentData->imageSize32.v
                                                                   bitsPerSample:gFilterRecord->depth
                                                                 samplesPerPixel:gFilterRecord->planes
                                                                        hasAlpha:NO 
                                                                        isPlanar:NO 
                                                                  colorSpaceName:mapImageModeToColorSpace(gFilterRecord->imageMode) 
                                                                     bytesPerRow:gFilterRecord->inRowBytes
                                                                    bitsPerPixel:gFilterRecord->depth*gFilterRecord->planes];

NSLog(@"LoadImageFromSDK : Bitmap created = %@", bitmapTmp);

[[bitmapTmp TIFFRepresentation] writeToFile:@"/Users/someuser/temp/sample.tif" atomically:YES];


NSImage *imageTmp = [[NSImage alloc] initWithSize:[bitmapTmp size]];
[imageTmp addRepresentation:bitmapTmp];
NSLog(@"LoadImageFromSDK : Image created = %@", imageTmp);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top