几何尺寸与公差论坛------致力于产品几何量公差标准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-06, 05:28 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】maximal resolution on bmp-expor

maximal resolution on bmp-export?
maximal resolution on bmp-export?
hello
i use a bmp export which i mainly copied from cmd_bmpout.cpp. altough it is not very fast, i works alright. when i try to export a large drawing ( 1189x841 mm ) with a resolution of 600 i get an "eextended error". if i try this with a resolution of 400 i do get a result, but the resulting drawing has a reduced width. it is then deformed, i.e. circles become ellipses and so on. i attached a tif-file to demonstrate the deformation.
is there a maximal value for this export?
here is the code i use:
code:
int commonfunctions::writebmp( oddbdatabaseptr pdb, long resolution, odstring targetfile )
{
int rcode = rc::r_wrtbmp;
try{
//code from cmd_bmpout
odgsmoduleptr pgs = odrxdynamiclinker()->loadmodule(dd_t("winopengl_2.06_9.gs"), false);
odgsdeviceptr pdevice = pgs->createbitmapdevice();
odgicontextfordbdatabaseptr pctx = odgicontextfordbdatabase::createobject();
pctx->setdatabase(pdb);
// extents of active layout
pdevice = oddbgsmanager::setupactivelayoutviews(pdevice, pctx);
odabstractviewpeptr pdeviceview;
odgsviewptr pdv;
odrxobjectptr playoutview;
if (!pdb->gettilemode())
{ // paper space
pdv = odgspaperlayouthelperptr(pdevice)->overallview();
pdeviceview = pdv;
oddblayoutptr playout = pdb->currentlayoutid().safeopenobject();
oddbobjectid overallvpid = playout->overallvportid();
oddbviewportptr pactivevp = overallvpid.safeopenobject();
playoutview = pactivevp;
}
else
{ // model space
pdv = odgsmodellayouthelperptr(pdevice)->activeview();
pdeviceview = pdv;
oddbviewporttableptr pvpt = pdb->getviewporttableid().safeopenobject();
oddbviewporttablerecordptr pactivevp = pvpt->getactiveviewportid().safeopenobject();
playoutview = pactivevp;
}
// get extents from current layout
odgeboundblock3d bbox;
odabstractviewpeptr playoutviewpe(playoutview);
playoutviewpe->viewextents(playoutview, bbox);
pdeviceview->zoomextents(pdv, &bbox);
int ncolorbits = 24;
pdevice->properties()->putat("bitperpixel", odrxvariantvalue(oduint32(ncolorbits)));
odcolorref bg = odrgb(255,255,255); // palette background
pctx->setpalettebackground(bg);
const odcolorref* palette = odcmacadpalette(bg);
odgspalette ppalcpy;
ppalcpy.insert(ppalcpy.begin(), palette, palette+256);
ppalcpy[0] = bg;
pdevice->setlogicalpalette(ppalcpy.asarrayptr(), 256);
double width = bbox.maxpoint().x - bbox.minpoint().x;
double height = bbox.maxpoint().y - bbox.minpoint().y;
double x = ( width/25.4 ) * resolution;
double y = ( height/25.4 ) * resolution;
//round
long xsize = (long)floor(x+0.5);
long ysize = (long)floor(y+0.5);
odgsdcrect gsrect(0, xsize, ysize, 0 );
pdevice->onsize(gsrect);
pctx->setplotgeneration(1);
pdevice->setbackgroundcolor(bg);
pdevice->update();
savebitmap( odgirasterimageptr(pdevice->properties()->getat("rasterimage")), targetfile );
rcode = rc::r_ok;
} catch( oderror e ){
odstring s = e.description();
odresult r = e.code();
oderrorcontext * ec = e.context();
}
return rcode;
}
edit:fff"> i just found out that exporting large dxf-drawings uses too much ram, that is probably why the error is thrown. it seems that the whole bmp is created in ram, which takes too much space when the drawing exceeds a certain dimension...
i am now looking for an alternative export. it doesn't need to be a bmp file, i just didn't find anything else in the examples and on this forum. my goal is to produce a tif file (black and white, ccitt t.6 fax 4). can anyone help me, please?
thanks for your help.
martin
attached files

hi,
yes, bmp export has resolution limits. it invokes with createdibsection() winapi function, which can't create rasters with big resolutions (unfortunatelly, i can't found any limit values in documentation, but this values depends on ram).
you can test your bmp export with another devices (wingdi, windirectx)?
does resulting raster still deformed?
i was just editing my first post when you replied... thanks for the info.
i've tried to load different modules and generate a bitmap (28087x19866 pixel):
- winbitmap_2.06_9.gs -> oderror: eoutofmemory
- wingdi_2.06_9.gs -> oderror: eextendederror
- windirectx_2.06_9.gs -> oderror: eextendederror
- winopengl_2.06_9.gs -> oderror: eextendederror
some of the modules worked for a bitmap-size of 18000x13000 (rounded..). the problem is clear, i have too little ram for a bitmap of this size. nevertheless i need to produce a tif file with this size. so if anyone knows a better way (and there must be one...) of creating a tif-file out of a dxf-file i'd be very happy to hear from you.
currently i use the bitmap-export and convert the resulting bmp-file into a tif file using the cximage library. actually i don't even need the colors, so a 1-bit bitmap would suffice. just didn't succeed on altering the code in my previous post and make it work with 1-bit color. any suggestions on that?
thanks for any help.
martin

hi,
you can use file mapping object, to avoid memory limits. the devices source code comes with our release, so you can modify gsdibsection::createdib() and gsdibsection::destroy() [exgsbitmapdevice.cpp] for use file mapping instead ram. see createdibsection() and createfilemapping() functions documentation in msdn.
additionally, you can use 1, 2, 4, 8, or 16 bpp instead of 24:
code:
int ncolorbits = 1; // monochrome
pdevice->properties()->putat("bitperpixel", odrxvariantvalue(oduint32(ncolorbits)));
solved
hello amark,
thanks for your help. i've reduced the color depth from 24 to 1 bit. this clearly uses much less memory and therefore solves my problem. looking back this solution is simple and very obvious. i tried the same earlier, but somehow thought i had to change more than just the bits per pixel and did not get my messed up code to work. well, i've learned...
thanks again.
martin
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】hatch outline resolution yang686526 DirectDWG 0 2009-05-05 11:54 AM
【转帖】error in export to bmp yang686526 DirectDWG 0 2009-05-05 09:37 AM
【转帖】bmp of 32bit color yang686526 DirectDWG 0 2009-05-04 04:54 PM
【转帖】bmp export and whitespace yang686526 DirectDWG 0 2009-05-04 04:54 PM


所有的时间均为北京时间。 现在的时间是 05:17 AM.


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