首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在更新到16.0.3之后,AI插件的自定义游标丢失(OS )

在更新到16.0.3之后,AI插件的自定义游标丢失(OS )
EN

Stack Overflow用户
提问于 2012-12-18 03:17:11
回答 1查看 435关注 0票数 1

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-12-18 17:28:53

我昨天刚处理了这个问题。AIResourceManagerHandle看起来是有效的,但是对sAIUser->SetCursor()的调用返回了一个CANT错误,不管我尝试了什么。光标PNGI ID是正确的,XML_热点ID是正确的,等等。我甚至尝试为光标制作各种更高分辨率的PNG,这也没有帮助。甚至还有一个较新版本的SDK,但我对它做了一个不同的处理,唯一的更改是一些无关的注释。

我只是通过使用Mac平台代码来解决这个问题,然后继续使用Windows的Illustrator代码。我们已经有了一个游标类,这使得它更加容易(如果您还没有游标类的话,您可能想要创建一个)。最后看起来是这样的:

代码语言:javascript
复制
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++和/或#import <AppKit/AppKit.h>

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13925741

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档