yourwcd 发表于 2007-1-16 09:12:00

如何将.gif图片保存到数据字典?

<p>请教各位高手:</p><p>  我想把硬盘上的.gif图片保存到数据字典,然后可以从数据字典中读取数据再还原到硬盘上.</p><p>可是.gif如何保存到数据字典?我是用下面的格式保存字符串等信息的,但不知道图片怎么保存,</p><p>发现有一个&nbsp;&nbsp;AcDb::kDxfBinaryChunk类型,字面上是二进制块,不知道是保存什么类型的</p><p>&nbsp;&nbsp;&nbsp;&nbsp; AcDbDictionary *pNamedobj, *pDict;<br/>&nbsp;&nbsp;&nbsp;&nbsp; acdbHostApplicationServices()-&gt;workingDatabase()<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt;getNamedObjectsDictionary(pNamedobj, AcDb::kForWrite);</p><p>&nbsp;&nbsp;&nbsp; if (pNamedobj-&gt;getAt("ASDK_DICT", (AcDbObject*&amp;) pDict,<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AcDb::kForWrite) == Acad::eKeyNotFound)<br/>&nbsp;&nbsp;&nbsp; {<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pDict = new AcDbDictionary;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AcDbObjectId DictId;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pNamedobj-&gt;setAt("ASDK_DICT", pDict, DictId);<br/>&nbsp;&nbsp;&nbsp; }<br/>&nbsp;&nbsp;&nbsp; pNamedobj-&gt;close();</p><p>&nbsp;&nbsp;&nbsp; // Add a new xrecord to the ASDK_DICT dictionary.<br/>&nbsp;&nbsp;&nbsp; //<br/>&nbsp;&nbsp;&nbsp; AcDbXrecord *pXrec = new AcDbXrecord;<br/>&nbsp;&nbsp;&nbsp; AcDbObjectId xrecObjId;<br/>&nbsp;&nbsp;&nbsp; pDict-&gt;setAt("XREC1", pXrec, xrecObjId);<br/>&nbsp;&nbsp;&nbsp; pDict-&gt;close();<br/>&nbsp;&nbsp;&nbsp; struct resbuf *pHead;<br/>&nbsp;DWORD flen; <br/>&nbsp;CFile bfile;<br/>&nbsp;CMemFile buffer;<br/>&nbsp;BYTE *psf;<br/>&nbsp;bfile.Open("c:\\abc.gif",CFile::modeReadWrite,NULL);<br/>&nbsp;flen=bfile.GetLength(); <br/>&nbsp;psf=(BYTE*)new char; <br/>&nbsp;bfile.Read(psf,flen);<br/>&nbsp;bfile.Close();</p><p>&nbsp;&nbsp;&nbsp; pHead = acutBuildList(<br/>&nbsp;&nbsp;AcDb::kDxfText,"1",<br/>&nbsp;&nbsp;//AcDb::kDxfBinaryChunk,<br/>&nbsp;&nbsp;//*psf,<br/>&nbsp;&nbsp;AcDb::kDxfInt16,&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *psf,</p><p>&nbsp;&nbsp;AcDb::kDxfText,&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "This is a test Xrecord list",<br/>&nbsp;&nbsp;AcDb::kDxfText,<br/>&nbsp;&nbsp;"DocumentId",<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0);</p><p>&nbsp;&nbsp;&nbsp; pXrec-&gt;setFromRbChain(*pHead);</p><p>&nbsp;&nbsp;&nbsp; acutRelRb(pHead);<br/>&nbsp;&nbsp;&nbsp; pXrec-&gt;close();<br/></p>

老牛 发表于 2007-1-17 11:30:00

AcDb::kDxfBinaryChunk表示保存的数据是以二进制块的方式。理论上所有的数据都是由二进制方式保存。我想这种方式应该可以,你可以试试看。

yourwcd 发表于 2007-1-19 09:11:00

问题解决,将图片文件进行BASE64编码后作为字符串存入数据字典就可以了。
页: [1]
查看完整版本: 如何将.gif图片保存到数据字典?