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


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


 
 
主题工具 搜索本主题 显示模式
旧 2009-05-07, 12:20 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】raster image dont display1

raster image don't display!
raster image don't display!
hi,all
please help me ,i use loadrasterimage(odstring filename) in my ocx,but in my ocx application don't display,in autocad 2004 is fine,why? is any module not load?
please look the attachments file.

raster image clipping
hi,
i test attached dwg with 2.6.1.
for images, which incorrectly displayed, enabled "show clipping" mode. clipping region is not correct, and autocad skips clipping of images in this case, but dd processes images clipping with this clipping boundary.
to resolve problem in the drawing, you can disable image clipping, delete invalid clipping boundary from image, or enter new (valid) clipping boundary.
hi,amark
to resolve problem in the drawing, you can disable image clipping, delete invalid clipping boundary from image, or enter new (valid) clipping boundary.[/quote]
are the images have questions, or my code have some bugs?
my code is :
code:
void cdwgviewerview::insertimage(cdwgviewerdoc* pdoc, cdwgviewerview* pview,cstring imagefile,odgepoint3d basepoint,oduint32 w,oduint32 h )
{
double scalefactor = 1.0;
double rotationangle = 0.0;
oduint32 nwidth, nheight;
odstring imagename;
// get image to add
imagename = odstring(imagefile);
// open model space for write getdocument()->m_pdb
oddbblocktablerecordptr precord = pdoc->m_pdb->getmodelspaceid().safeopenobject(oddb::kforwrite);
// ensure that this drawing has an image dictionary
oddbobjectid imagedictid = oddbrasterimagedef::createimagedictionary(precord->database());
// open the image dictionary.
oddbdictionaryptr pimagedict = imagedictid.safeopenobject(oddb::kforwrite);
// check the dictionary for specified image definition name
int ind1 = imagename.reversefind('\\');
int ind2 = imagename.reversefind('.');
odstring key;
if ( ind1 != -1 )
{
if ( ind2 != -1 )
key = imagename.mid(ind1+1, ind2 - ind1 - 1);
else
key = imagename.mid(ind1+1);
}
else
{
if ( ind2 != -1 )
key = imagename.mid(0, ind2);
else
key = imagename;
}
nwidth = 1;
nheight = 1;
// try to load image and detect it size
// messagebox(imagename.c_str());
odrxrasterservicesptr prassvcs =:drxdynamiclinker()->loadapp(l"rxrasterservices");
odgirasterimageptr rast =prassvcs->loadrasterimage(imagename);
// if ( !rast.isnull() )
//
// odgevector2d rastsize= oddbrasterimagedef::size();

// rast.nheight=nheight;
// rast.nwidth=nwidth;
oddbobjectid imagedefid = pimagedict->getat(key);
if (imagedefid.isnull())
{
// an image definition was not find, so create new one
oddbrasterimagedefptr pimagedef = oddbrasterimagedef::createobject();
imagedefid = pimagedict->setat(key, pimagedef);

// set remaining imagedef attributes.
pimagedef->setsourcefilename(imagename);
// pimagedef->setimage(odgirasterimagedesc::createobject(w, h, odgirasterimage::kinch));
pimagedef->setimage(rast);

// check raster variables
oddbrastervariablesptr prvars = oddbrastervariables:penrastervariables(precord->database(), oddb::kforwrite);
if (odgirasterimage::knone == prvars->userscale())
{
prvars->setuserscale(odgirasterimage::kmillimeter);
prvars->setimageframe(oddbrastervariables::kimageframeabove);
prvars->setimagequality(oddbrastervariables::kimagequalityhigh);

}
}

// add image entity, which references the above imagedef. an imagedef
// can be used by multiple image entities.
oddbrasterimageptr pdbraster = oddbrasterimage::createobject();

// add image entity to block.
precord->appendoddbentity(pdbraster);

// set remaining image attributes.
pdbraster->setimagedefid(imagedefid);

// odgevector3d nu(odgevector3d::kxaxis), nv(odgevector3d::kyaxis);
// nu.rotateby(rotationangle, odgevector3d::kzaxis);
// nu *= scalefactor;
//
// nv.y = nv.y * nheight / nwidth; // take into account aspect ratio
// nv.rotateby(rotationangle, odgevector3d::kzaxis);
// nv *= scalefactor;
odgevector2d imagesize= pdbraster->imagesize(false);

pdbraster->setorientation(basepoint, odgevector3d(w/25.4, 0, 0), odgevector3d(0.0, h/25.4, 0));

pdbraster->setdisplayopt(oddbrasterimage::kshow, true);
pdbraster->setdisplayopt(oddbrasterimage::kshowunaligned, true);
pdbraster->setbrightness(oduint8(50));
pdbraster->setcontrast(oduint8(50));

odgepoint2darray pts;

// as a second point we have to use image size
pts.push_back(odgepoint2d(0, 0));
pts.push_back(odgepoint2d(w/2, 0));
pts.push_back(odgepoint2d(w/2, h/2));
pts.push_back(odgepoint2d(0, h/2));
pts.push_back(odgepoint2d(0, 0));
pdbraster->setclipboundary(pts);

pdbraster->setdisplayopt(oddbrasterimage::kshow, true);
pdbraster->setdisplayopt(oddbrasterimage::kshowunaligned, true);
pdbraster->setdisplayopt(oddbrasterimage::kclip, true);
// // pdbraster->setclipped(true);
return;
}please help me!

raster image clipping
hi,
boundary region for image specified incorrectly.
to specify rectangular clipping boundary use two points, instead of five.
for example (default values for entire image in example drawing):
code:
odgepoint2darray pts;

// as a second point we have to use image size
pts.push_back(odgepoint2d(-0.5, -0.5));
pts.push_back(odgepoint2d(156.5, 131.5));
pdbraster->setclipboundary(pts);btw, in example drawing i see following values in boundary array:
{ 0, 0 },
{ 6, 0 },
{ 6, 1 },
{ 0, 1 },
{ 0, 0 }
, this values too small to display entire image.
hi,amark,
the b.dwg file in the mfcappdll.exe display is ok,why?
hi,amark
i think the question is not the clip boundary,the rect is small or large not effect the image display.

what version of dd you are use?
hi amark,
dd version is 2.6.1.
last edited by jum_xie; 6th august 2008 at 06:16 pmfff">.

raster image don't display
hi,
i test insertimage() function in 2.6.1. it is works correctly and i could not reproduce wrong behaviour.
please, answer on the following questions:
1) is rasterprocessor module loaded (it is needed for display/convert raster images)?
2) does other images displayed correctly in your application (in files saved by acad, for example)?
3) what vectorizer you are use? test rendering with other vectorizers if you can.

hi,amark,
1.rasterprocessor load or not,the question has exists
2.i replace the wingdi.gs with winopengl.gs,the question has exists
i think the question is the ocx framework and the mfcapp framework different,i insert the raster image in the dwg with the autocad 2004, use the ocx app open the dwg file,the image don't display,but in singledoc.exe(the sample in dd nonlibs) is ok.
the ocx app in the attachments, please put bbb.dwg in the d:\
please help me!

raster image don't display
hi, jum_xie,
i check attached ocx, and found following problem:
raster image has jpeg file format (c:\a.jpg), but application compiled without jpeg support.
see exgirasterimage.cpp:
code:
#ifdef raster_jpeg6b
#undef far
extern "c"
{
#include "jpeglib.h"
}so, to enable jpeg support you must:
- add raster_jpeg6b preprocessor definition to project.
- add include directory ".\dwgdirect\thirdparty\jpeg-6b" to vs options.
- link with dd_vc6md_jpeg.lib library.
hi,amark,
the problem has been resolved,but i want store the rasterimage in the dwg file,can you give me some advice?
where is no "standard" autocad's entity which stores raster data inside dwg file.
sergey slezkin
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】question of creating raster image yang686526 DirectDWG 0 2009-05-07 12:15 PM
【转帖】problem with exporting raster image to pdf yang686526 DirectDWG 0 2009-05-06 11:17 PM
【转帖】image raster and image ole yang686526 DirectDWG 0 2009-05-06 03:40 PM
【转帖】image dictionary yang686526 DirectDWG 0 2009-05-06 03:39 PM
【转帖】how to get and change an image name yang686526 DirectDWG 0 2009-05-06 02:39 PM


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


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多