Skip navigation
Eric Shmeric
Currently Being Moderated

Developing filter plug-in: having trouble storing image buffer in the registry

Jun 24, 2013 2:09 AM

Hi guys, I'm new to plug-in development and having a bit of trouble with storing information to the photoshop registry. My plug-in has two buttons, "capture" and "apply". When the capture button is pressed, the filter needs to grab whatever image data has focus. Then the user would give a different image focus, run the filter again and press "apply", transfering information from the captured image to the new image. The problem is that filter memory is wiped between executions so I need to save the captured image to the registry (I think anyway, please let me know if there's anything easier I could be doing).

 

Anyway, I'm modifying the dissolve example from the SDK, I'm in DissolveRegistry.cpp

 

In dissolve.h I define an image buffer and it's length

Ptr transferBuffer;

int32 transferBufferLength;

 

 

Then in DissolveRegistry.cpp I try to write and read this information as follows

 

//WRITE BUFFER

 

 

 

 

err = descriptorProcs->PutInteger(descriptor, keyTransferLength, gData->transferBufferLength);

if (err) goto returnError;

err = descriptorProcs->PutData(descriptor, KeyTransfer, gData->transferBufferLength, gData->transferBuffer);

if (err) goto returnError;

 

//READ BUFFER

err = descriptorProcs->GetInteger(descriptor, keyTransferLength, &gData->transferBufferLength);
if (err) goto returnError;
err = descriptorProcs->GetData(descriptor, KeyTransfer, gData->transferBuffer);
if (err) goto returnError;

 

It seems to write okay (by okay I mean it doesn't actually throw an error), and the buffer length seems to be working okay (unless I'm missunderstanding my debugger). When I try to read the buffer though, I get a "bad pointer" error. I guess I don't understand how the PutData function works, does it not set the pointer to the buffer I saved? Does anyone have any example code for how to do this correctly?

 

Sorry if this code is terrible. I have almost no experience with this sort of thing and I can't find any documentation. Any help would be much appreciated!

 

Kindest Regards,

Eric

 
Replies
  • Currently Being Moderated
    Aug 5, 2013 2:33 PM   in reply to Eric Shmeric

    You need to create space to copy the data before the GetData call.

     

    Something like

     

    gData->transferBuffer = new char[gData->transferBufferLength];

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points