Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 302535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:06:22+00:00 2026-05-12T07:06:22+00:00

I’m implementing a Photoshop plugin on the Mac, and I’m doing it using Cocoa.

  • 0

I’m implementing a Photoshop plugin on the Mac, and I’m doing it using Cocoa. Doing ok so far, but the next step is to provide a “preview” image, as a part of my plugin window, and I’m stuck. I’m a n00b Obj-C programmer, which isn’t really helping 🙂

So far I’ve got something like this:

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");

At the moment, it crashes horribly on:
09/07/22 10:23:32 AM Adobe Photoshop Elements[46628] *** NSCopyMemoryPages(0x0, 0x245f4000, 2265088) failed

I’m probably calculating the size of inData incorrectly. Help?

Also, is NSImage going to be able to interpret that image data blob correctly? Or should I give it up and just do a pixel-by-pixel mapping into the NSImage?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T07:06:22+00:00Added an answer on May 12, 2026 at 7:06 am

    Ok, that was way more painful to figure out than I had anticipated. Also, kudos to NVidia for posting this PDF which is a better explanation of the Photoshop SDK filter record than the actual SDK docs.

    This code actually reads the inData and produces a usable NSImage (lots of logging just to figure out what it is doing, feel free to remove) in addition to the sample tif file for debugging purposes.

    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);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 299k
  • Answers 299k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If the }else{ is called, nothing gets returned from the… May 13, 2026 at 7:40 pm
  • Editorial Team
    Editorial Team added an answer I'm doing it with the following code: UITableViewCell *cell =… May 13, 2026 at 7:40 pm
  • Editorial Team
    Editorial Team added an answer Have a look at Split a string using String.split() Spmething… May 13, 2026 at 7:40 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want use html5's new tag to play a wav file (currently only supported
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I've got a string that has curly quotes in it. I'd like to replace
In order to apply a triggered animation to all ToolTip s in my app,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.