Article View: adobe.acrobat.sdk
Article #67Re: How to create Button Icon from PNG?
From: NoSmoking
Date: Tue, 17 Mar 2009 10:10
Date: Tue, 17 Mar 2009 10:10
40 lines
1690 bytes
1690 bytes
Thanks,Leonard
I have just see the sample in the Acrobat 9 SDK.
The sample use png tool button for MAC,not Windows.
But i tried it under Windows XP & Acrobat 8,it's OK.
The code show below:
AVIconBundle6 createPNGIcon(const std::string& strName)
{
//strName is the png file path
if(strName.empty())return NULL;
AVIconDataRec iconData;
iconData.dataStm = NULL;
iconData.eColorFormat = kAVIconColor;
ASFile asf = NULL;
ASPathName aspn = ASFileSysCreatePathFromCString(NULL, strName.c_str());
if(!aspn)return NULL;
if(ASFileSysOpenFile(NULL, aspn, ASFILE_READ, &asf) != 0)
return NULL;
ASUns32 dataSize = ASFileGetEOF(asf);
if(dataSize <= 0)return NULL;
ASUns8 *data = (ASUns8 *)ASmalloc(dataSize + 1);
ASFileRead(asf, (char *)data, dataSize);
ASFileClose(asf);
iconData.dataStm = ASMemStmRdOpen((char *)data, dataSize);
if(!iconData.dataStm){
ASfree(data);
return NULL;
}
return AVAppCreateIconBundle6 (kAVIconPNG, &iconData, 1);
}
AVToolButton toolButton = AVToolButtonNew ("mytoolname", createPNGIcon("test.png"), false, false);
Technical Details
Message-ID:
<59b838f6.4@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!newshub.sdsu.edu!webcrossingReferences:
<59b838f6.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: 10177e,bae9b4eca948d72 X-Google-Attributes: gid10177e,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: NoSmoking@adobeforums.com Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.acrobat.sdk Subject: Re: How to create Button Icon from PNG? Message-ID: <59b838f6.4@webcrossing.la2eafNXanI> Date: Tue, 17 Mar 2009 03:10:40 -0700 References: <59b838f6.-1@webcrossing.la2eafNXanI> Lines: 42 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit