查看单个帖子
旧 2009-05-06, 03:59 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】inserting images into dxfdwg

inserting images into dxf/dwg
inserting images into dxf/dwg
hi,
i'd like to insert images into dxf file. i saw examples and i think that did everything like there, but when i open the dxf file in autocad images are't displayed . my code is similar to this:
code:
oddbobjectid imagedictid = oddbrasterimagedef::createimagedictionary(m_pdxfdatabase);
oddbdictionaryptr pimagedict = imagedictid.safeopenobject(oddb::kforwrite);
odstring key = "asdasd";

oddbobjectid imagedefid = pimagedict->getat(key);
if (imagedefid.isnull())
{
odrxmoduleptr pmodule = :drxdynamiclinker()->loadmodule("rxrasterservices.drx");
odgirasterimageptr prasterimage = ((odrxrasterservicesptr)pmodule)->loadrasterimage(m_imagename);

oddbrasterimagedefptr pimagedef = oddbrasterimagedef::createobject();
imagedefid = pimagedict->setat(key, pimagedef);
pimagedef->setsourcefilename(m_imagename);
pimagedef->setimage(prasterimage);
if(!prasterimage.isnull())
{
nheight = prasterimage->pixelheight();
nwidth = prasterimage->pixelwidth();
}
oddbrastervariablesptr prvars = oddbrastervariables:penrastervariables(m_pdxfdatabase, oddb::kforwrite);
if (odgirasterimage::knone == prvars->userscale())
{
prvars->setuserscale(odgirasterimage::kmillimeter);
prvars->setimageframe(oddbrastervariables::kimageframeabove);
prvars->setimagequality(oddbrastervariables::kimagequalityhigh);
}
}
oddbrasterimageptr pdbraster = oddbrasterimage::createobject();
blockrecord->appendoddbentity(pdbraster);
pdbraster->setimagedefid(imagedefid);
odgepoint3d pt(ptx, pty, 0.0);
pdbraster->setorientation(pt, odgevector3d(50, 0, 0), odgevector3d(0, 50, 0));
pdbraster->setdisplayopt(oddbrasterimage::kshow, true);
pdbraster->setdisplayopt(oddbrasterimage::kshowunaligned, true);
the image is loaded. its width and height is correct. the image file is placed in the same directory where the dxf file is.
should i do something more ?
thanks
marcin
attached images
you saved absolute path to the image file: "c:\image33.bmp"
autocad fails to find it in this location. if file path is changed to "image33.bmp" it shows the image having found the file in the same folder as dwg.
sergey slezkin
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)