photoshop plugin SDK 调用旋转功能 c++
时间: 2023-07-29 09:11:19 浏览: 176
调用 Photoshop Plugin SDK 中的旋转功能需要使用 PISuites.h 头文件中的函数。具体步骤如下:
1. 引入头文件
```c++
#include "PISuites.h"
```
2. 获取 SPBasicSuite 指针
```c++
SPBasicSuite *sSPBasic = NULL;
if (sSPBasic == NULL) {
error = sSPBasicAcquire(&sSPBasic);
}
```
3. 获取 SPPluginRef 对象
```c++
SPPluginRef pluginRef = NULL;
error = sSPBasic->AcquireSuite(kSPPluginSuite, kSPPluginSuiteVersion, (const void **)&pluginRef);
```
4. 获取 SPSActionControlSuite 对象
```c++
SPSActionControlSuite *sSPSActionControl = NULL;
error = sSPBasic->AcquireSuite(kSPSActionControlSuite, kSPSActionControlSuiteVersion, (const void **)&sSPSActionControl);
```
5. 设置旋转参数
```c++
SPActionReference actionRef = NULL;
SPActionDescriptor actionDesc = NULL;
SPActionDescriptor resultDesc = NULL;
char *rotateMode = "byAngle";
double rotateAngle = 30.0;
actionRef = sSPSActionControl->NewActionReference();
error = sSPSActionControl->PutEnumerated(actionDesc, kSPHostAutoInterp, kSPRotateTool, kSPRotateTool);
error = sSPSActionControl->PutEnumerated(actionDesc, kSPHostAutoInterp, kSPByAbsolute, kSPByAbsolute);
error = sSPSActionControl->PutUnitFloat(actionDesc, kSPHostAutoInterp, kSPAngleUnit, rotateAngle);
```
6. 调用旋转功能
```c++
error = sSPSActionControl->Play(actionRef, actionDesc, kDialogOff, &resultDesc);
```
完整代码示例:
```c++
#include "PISuites.h"
int main(int argc, char **argv) {
SPErr error = kSPNoError;
// 获取 SPBasicSuite 指针
SPBasicSuite *sSPBasic = NULL;
if (sSPBasic == NULL) {
error = sSPBasicAcquire(&sSPBasic);
}
// 获取插件引用
SPPluginRef pluginRef = NULL;
error = sSPBasic->AcquireSuite(kSPPluginSuite, kSPPluginSuiteVersion, (const void **)&pluginRef);
// 获取 SPSActionControlSuite 对象
SPSActionControlSuite *sSPSActionControl = NULL;
error = sSPBasic->AcquireSuite(kSPSActionControlSuite, kSPSActionControlSuiteVersion, (const void **)&sSPSActionControl);
// 设置旋转参数
SPActionReference actionRef = NULL;
SPActionDescriptor actionDesc = NULL;
SPActionDescriptor resultDesc = NULL;
char *rotateMode = "byAngle";
double rotateAngle = 30.0;
actionRef = sSPSActionControl->NewActionReference();
error = sSPSActionControl->PutEnumerated(actionDesc, kSPHostAutoInterp, kSPRotateTool, kSPRotateTool);
error = sSPSActionControl->PutEnumerated(actionDesc, kSPHostAutoInterp, kSPByAbsolute, kSPByAbsolute);
error = sSPSActionControl->PutUnitFloat(actionDesc, kSPHostAutoInterp, kSPAngleUnit, rotateAngle);
// 调用旋转功能
error = sSPSActionControl->Play(actionRef, actionDesc, kDialogOff, &resultDesc);
return error;
}
```
阅读全文