几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】inserting image (http://www.dimcax.com/hust/showthread.php?t=16895)

yang686526 2009-05-06 03:58 PM

【转帖】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.


所有的时间均为北京时间。 现在的时间是 06:30 PM.