高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】inserting image
inserting image
inserting image
hi,
i am trying to insert an image(.bmp) to .dwg file. but for some reason, i am not able to show up the inserted image on view. am i missing any step? here is what i did:
code:
//create image in memory
odrxrasterservicesptr prassvcs = odrxdynamiclinker()->loadapp(rx_raster_services_appname);
odgirasterimageptr rast = prassvcs->loadrasterimage(simgpath);
//add image to dictionary
odstring skey =sfilename;
oddbrasterimagedefptr pimgdef = oddbrasterimagedef::createobject();
pimgdef->setsourcefilename(simgpath);
pimgdef->setimage(rast);
oddbobjectid pimgdefid = pimgdict->setat(skey, pimgdef);
oduint32 uiwidth = rast->pixelwidth();
oduint32 uiheight = rast->pixelheight();
//clipping boundary
odgepoint2darray clippts;
clippts.push_back(odgepoint2d(2, 2));
clippts.push_back(odgepoint2d(uiwidth/2, 2));
clippts.push_back(odgepoint2d(uiwidth/2, uiheight/2));
clippts.push_back(odgepoint2d(2, uiheight/2));
clippts.push_back(odgepoint2d(2, 2));
m_pimg->setclipboundary(clippts);
m_pimg->setclipped(true);
//set scale and rotation
odgematrix3d scalemtrx;
odgescale3d scale;
scale.set(m_dscalex, m_dscaley, m_dscalez);
scalemtrx.settoidentity();
scalemtrx.settoscaling(scale,odgepoint3d(odgepoint3d::korigin));
odgevector3d ucorner(odgevector3d::kxaxis), vonplane(odgevector3d::kyaxis);
ucorner.rotateby(imgdlg.m_drotation, getviewingdirection());
ucorner.transformby(scalemtrx);
vonplane.y = m_vonplane.y * uiheight / uiwidth;
vonplane.rotateby(imgdlg.m_drotation, getviewingdirection());
vonplane.transformby(scalemtrx);
odgepoint3d pt(dptx, dpty, dptz);
m_pimg->setorientation(pt, ucorner, vonplane);
m_pimg->setdisplayopt(oddbrasterimage::kshow, true);
//add to database
oddbblocktablerecordptr pspace = database()->getactivelayoutbtrid().safeopenobject(oddb::kforwrite);
database()->startundorecord();
pspace->appendoddbentity(m_pimg);
m_pimg.release();
thanks.
resolved
never mind... resolved... couple of things i did: changed rastersvcs and added default values for raster variables and now seems to be working.
thanks.
|