更新到 Adobe Illustrator 16.0.3 后,AI 插件的自定义光标丢失 (OS X)



>有人遇到同样的事情吗?我们的Adobe AI插件有一个自定义光标。它是一个PNG文件和一个XML描述,PNG和XML在.r REZ文件中声明。sUser->SetCursor(resID, iResourceManager);用于设置光标。它可以在AI CS6上运行,但是在安装16.0.3更新包后,没有自定义光标,而只有默认的黑色箭头。我知道此更新对光标进行了一些更改,因为它支持高清屏幕分辨率,但 AI 光标可以调整大小而不会丢失任何细节。如何添加游标资源?

我昨天刚刚处理了这个问题。AIResourceManagerHandle似乎是有效的,但无论我尝试什么,对sAIUser->SetCursor()的调用都返回了CANT错误。光标PNGI ID 正确,XML_热点 ID 正确等。我什至尝试为光标制作各种更高分辨率的 PNG,但也没有帮助。甚至还有一个较新版本的SDK,但我对它进行了差异,唯一的变化是一些不相关的评论。

我只是通过使用Mac的平台代码来解决这个问题,并坚持使用Windows的Illustrator代码。我们已经有一个游标类,这使得它变得容易得多(如果你还没有游标类,你可能想创建一个)。它最终看起来像这样:

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 <AppKit/AppKit.h>某处。

最新更新