Plugin development: How to use the buffer suite?
Hello,
I am developing a Photoshop Filter plugin and I try to figure out how to update the deprecated buffer procs (gFilterRecord->bufferProcs) to the non-deprecated buffer suite.
I made a small test plugin, but it doesn't work as expected.
What am I doing wrong?
DLLEXPORT MACPASCAL
void ENTRYPOINT(short selector, FilterRecordPtr pb, intptr_t *data, short *result){
......
if (selector != filterSelectorAbout) {
char* xx = (char*)malloc(200);
// ======== 32 Bit ========
PSBufferSuite1* gPSBufferSuite32 = NULL;
if (pb->sSPBasic->AcquireSuite(kPSBufferSuite, kPSBufferSuiteVersion1, (const void**)&gPSBufferSuite32)) {
simplealert("no buffer suite 32"); // does not happen in Photoshop 7 and Photoshop CS 2
*result = errPlugInHostInsufficient;
return;
}
// Photoshop 7 on a 16GB system => 844,238,416 = 805 MiB?!
// Photoshop CS2 on a 16GB system => 1,600,846,272 = 1.53 GiB
unsigned32 free32 = gPSBufferSuite32->GetSpace();
sprintf(xx, "Space32 = %u", free32); simplealert(xx);
pb->sSPBasic->ReleaseSuite(kPSBufferSuite, kPSBufferSuiteVersion1);
// ======== 64 Bit ========
PSBufferSuite2* gPSBufferSuite64 = NULL;
if (pb->sSPBasic->AcquireSuite(kPSBufferSuite, kPSBufferSuiteVersion2, (const void**)&gPSBufferSuite64)) {
simplealert("no buffer suite 64"); // does not happen in Photoshop 7 and Photoshop CS 2
*result = errPlugInHostInsufficient;
return;
}
// Photoshop 7 on a 16GB system => 19,216,129 = 18 MiB?!
// Photoshop CS2 => Crash
unsigned64 free64 = gPSBufferSuite64->GetSpace();
sprintf(xx, "Space64 = %llu", free64); simplealert(xx);
pb->sSPBasic->ReleaseSuite(kPSBufferSuite, kPSBufferSuiteVersion2);
}
...........................
The 64 bit suite crashes with Photoshop CS2, and outputs a very low value on Photoshop 7.
I wonder why CS2/7 have the 64 bit suites at all, since they are 32 bit apps.
The SDK does not state the Unit-Of-Measure for the Space methods. I guess the result is measured in bytes?
Thank you for your help!