Plugins 更新到Adobe Illustrator 16.0.3后,AI插件的自定义游标丢失(OS X)
有人遇到过同样的事情吗?我们的AdobeAI插件有一个自定义光标。它是一个带有XML描述的PNG文件,PNG和XML在一个.r REZ文件中声明sUser->SetCursor(resID,iResourceManager)用于设置光标。它可以在AI CS6上工作,但是在安装了16.0.3更新包之后,没有自定义光标,只有默认的黑色箭头。我知道这次更新对光标做了一些更改,因为它支持高清晰度屏幕分辨率,但是AI光标可以调整大小而不丢失任何细节。如何添加光标资源?我昨天刚刚处理了这个问题。Plugins 更新到Adobe Illustrator 16.0.3后,AI插件的自定义游标丢失(OS X),plugins,cursor,adobe,adobe-illustrator,Plugins,Cursor,Adobe,Adobe Illustrator,有人遇到过同样的事情吗?我们的AdobeAI插件有一个自定义光标。它是一个带有XML描述的PNG文件,PNG和XML在一个.r REZ文件中声明sUser->SetCursor(resID,iResourceManager)用于设置光标。它可以在AI CS6上工作,但是在安装了16.0.3更新包之后,没有自定义光标,只有默认的黑色箭头。我知道这次更新对光标做了一些更改,因为它支持高清晰度屏幕分辨率,但是AI光标可以调整大小而不丢失任何细节。如何添加光标资源?我昨天刚刚处理了这个问题。aireso
airesourcemanagernandle
似乎是有效的,但是对sAIUser->SetCursor()
的调用返回了一个CANT
错误,无论我做了什么尝试。光标PNGI
ID是正确的,XML\uquot\code>热点ID是正确的,等等。我甚至尝试为光标制作各种更高分辨率的png,但这也没有帮助。甚至还有一个更新版本的SDK,但我对它进行了区分,唯一的变化是一些无关的注释
我只是通过使用Mac的平台代码来解决这个问题,并坚持使用Windows的Illustrator代码。我们已经有了一个cursor类,这使它变得更容易(如果您还没有cursor类的话,您可能想创建一个)。它最终看起来像这样:
class Cursor
{
public:
Cursor(const int cursorID_);
virtual ~Cursor();
virtual void enable();
private:
int __cursorID;
#if defined(MAC_ENV)
NSCursor* __cursorMac;
#endif
};
bool getResourceData(
const long type_,
const int id_,
char*& data__,
int& size__
) const
{
static const int oneMeg = 1048576;
data__ = NULL;
size__ = 0;
AIDataFilter* aidf = NULL;
AIErr error = sAIDataFilter->NewResourceDataFilter(
yourPluginRef,
type_,
id_,
"",
&aidf
);
if(error != kNoErr || !aidf)
return false;
// This is the max size to read when going in to ReadDataFilter(),
// and the actual size read when coming out.
size_t tmpSize = oneMeg;
data__ = new char[ oneMeg ];
error = sAIDataFilter->ReadDataFilter(aidf, data__, &tmpSize);
AIErr ulError = kNoErr;
while(aidf && ulError == kNoErr)
{
ulError = sAIDataFilter->UnlinkDataFilter(aidf, &aidf);
}
if(error != kNoErr)
{
delete[] data__;
return false;
}
size__ = tmpSize;
return true;
}
Cursor::Cursor(const int cursorID_)
{
this->__cursorID = cursorID_;
#if defined(MAC_ENV)
this->__cursorMac = nil;
char* pngData = NULL;
int pngDataSize = 0;
if(!getResourceData('PNGI', this->__cursorID, pngData, pngDataSize))
return;
NSPoint hs = NSMakePoint(0.0, 0.0);
char* xmlData = NULL;
int xmlDataSize = 0;
if(getResourceData('XML_', this->__cursorID, xmlData, xmlDataSize))
{
std::string xmlStr(xmlData, xmlDataSize);
// Parse xmlStr however you prefer. If you have an XML parser, rock on.
// Otherwise, the XML is so simple that an sscanf() call should work.
delete[] xmlData;
xmlData = NULL;
}
NSData* pngNSD = [[NSData alloc] initWithBytes:pngData length:pngDataSize];
delete[] pngData;
pngData = NULL;
NSImage* pngNSI = [[NSImage alloc] initWithData:pngNSD];
[pngNSD release];
pngNSD = nil;
this->__cursorMac = [[NSCursor alloc] initWithImage:pngNSI hotSpot:hs];
[pngNSI release];
pngNSI = nil;
#endif
}
Cursor::~Cursor()
{
#if defined(MAC_ENV)
if(this->__cursorMac)
{
[this->__cursorMac release];
this->__cursorMac = nil;
}
#endif
}
void Cursor::enable()
{
#if defined(MAC_ENV)
if(this->__cursorMac)
{
[this->__cursorMac set];
}
#elif defined(WIN_ENV)
sAIUser->SetCursor(this->__cursorID, yourCursorRsrcMgr);
#endif
}
根据项目的配置方式,您可能需要将源文件设置为编译为Objective-C++和/或#import
。我昨天刚刚处理了这个问题。airesourcemanagernandle
似乎是有效的,但是对sAIUser->SetCursor()
的调用返回了一个CANT
错误,无论我做了什么尝试。光标PNGI
ID是正确的,XML\uquot\code>热点ID是正确的,等等。我甚至尝试为光标制作各种更高分辨率的png,但这也没有帮助。甚至还有一个更新版本的SDK,但我对它进行了区分,唯一的变化是一些无关的注释
我只是通过使用Mac的平台代码来解决这个问题,并坚持使用Windows的Illustrator代码。我们已经有了一个cursor类,这使它变得更容易(如果您还没有cursor类的话,您可能想创建一个)。它最终看起来像这样:
class Cursor
{
public:
Cursor(const int cursorID_);
virtual ~Cursor();
virtual void enable();
private:
int __cursorID;
#if defined(MAC_ENV)
NSCursor* __cursorMac;
#endif
};
bool getResourceData(
const long type_,
const int id_,
char*& data__,
int& size__
) const
{
static const int oneMeg = 1048576;
data__ = NULL;
size__ = 0;
AIDataFilter* aidf = NULL;
AIErr error = sAIDataFilter->NewResourceDataFilter(
yourPluginRef,
type_,
id_,
"",
&aidf
);
if(error != kNoErr || !aidf)
return false;
// This is the max size to read when going in to ReadDataFilter(),
// and the actual size read when coming out.
size_t tmpSize = oneMeg;
data__ = new char[ oneMeg ];
error = sAIDataFilter->ReadDataFilter(aidf, data__, &tmpSize);
AIErr ulError = kNoErr;
while(aidf && ulError == kNoErr)
{
ulError = sAIDataFilter->UnlinkDataFilter(aidf, &aidf);
}
if(error != kNoErr)
{
delete[] data__;
return false;
}
size__ = tmpSize;
return true;
}
Cursor::Cursor(const int cursorID_)
{
this->__cursorID = cursorID_;
#if defined(MAC_ENV)
this->__cursorMac = nil;
char* pngData = NULL;
int pngDataSize = 0;
if(!getResourceData('PNGI', this->__cursorID, pngData, pngDataSize))
return;
NSPoint hs = NSMakePoint(0.0, 0.0);
char* xmlData = NULL;
int xmlDataSize = 0;
if(getResourceData('XML_', this->__cursorID, xmlData, xmlDataSize))
{
std::string xmlStr(xmlData, xmlDataSize);
// Parse xmlStr however you prefer. If you have an XML parser, rock on.
// Otherwise, the XML is so simple that an sscanf() call should work.
delete[] xmlData;
xmlData = NULL;
}
NSData* pngNSD = [[NSData alloc] initWithBytes:pngData length:pngDataSize];
delete[] pngData;
pngData = NULL;
NSImage* pngNSI = [[NSImage alloc] initWithData:pngNSD];
[pngNSD release];
pngNSD = nil;
this->__cursorMac = [[NSCursor alloc] initWithImage:pngNSI hotSpot:hs];
[pngNSI release];
pngNSI = nil;
#endif
}
Cursor::~Cursor()
{
#if defined(MAC_ENV)
if(this->__cursorMac)
{
[this->__cursorMac release];
this->__cursorMac = nil;
}
#endif
}
void Cursor::enable()
{
#if defined(MAC_ENV)
if(this->__cursorMac)
{
[this->__cursorMac set];
}
#elif defined(WIN_ENV)
sAIUser->SetCursor(this->__cursorID, yourCursorRsrcMgr);
#endif
}
根据项目的配置方式,您可能需要将源文件设置为编译为Objective-C++和/或#import
。非常感谢。我没有试过这个,因为现在我还有别的事要做。如果我有问题,我想再问你一次。非常感谢。我没有试过这个,因为现在我还有别的事要做。我会在下周做,如果我有问题,我想再问你一次。