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

extract thumbnail to file
extract thumbnail to file
the old opendwg kit had a call to pull the preview from a dwg into an outboard file. how do i accomplish this in dwgdirect?
thanks in advance

void oddbdatabase::writefile(odstreambuf* pfilebuff, oddb::savetype type, oddb: wgversion version, bool savethumbnailimage = false, int dxfprecision);
you have to set the fourth parameter in writefile method to true to save the file preview.

thanks much for the reply. i dont think i explained the question clearly. what i have is an open dwg, read only. what i want to do is locate the thumbnail bmp or wmf within it, and export that to an outboard bmp or wmf file, not a dwg file. or, at least get it into a data structure like odthumbnailimage so that i can then write that into a bmp/wmf file. thanks again for replying.

so i have gotten a little further
i now have the following;
odthumbnailimage odimage;
odstreambufptr sb = svcs.createfile(pname);
oddbgetpreviewbitmap(sb, &odimage);
sb.release;
at this point, odimage.bmp.empty() = false, meaning
i have gotten the bitmap into the structure.
is there a call to write that data structure out to a bmp, or metafile?
in the "old days", we had the call;
adextractbmptofile(adhandle, outfile);
which would locate the drawing's bmp, and write it to outfile in one call. couldnt there be something comparable in dwgdirect?

check void cpreviewdib: rawpreview(hdc dc, int x, int y, int width, int height)
method in odamfcapp example for reference

thanks for the reply, sergey
in fact, i have already looked there - the problem is, that code draws the bitmap, which i have no need to do.
the tool i am working on does not render the dwg, it pulls attribute, xref, and thumbnails out in a batch run. the only interface it has is a dialog that says "working".
this tool will pull data from tens of thousands of dwgs in one run.
we are trying to keep our extraction to ten drawings a second - even this results in several hours of processing.
what i want to do, is simply get the thumbnail out of the dwg into its own file.bmp, like adextractbmptofile() used to do.
am i correct in believing that you think i want to draw the bmp, or, are you saying i will need to project it to get a windows handle to it, and then save it to file myself from there?
if so, i would request the direct kit get the code from adextractbmptofile(), which worked great.
thanks again for the reply!

you can use oddbgetpreviewbitmap() function (declared in dbdatabase.h) to get oddbthumbnailimage object. its bmp member contains dib. to save bmp file you need to write bitmapfileheader to the file followed by contents of oddbthumbnailimage::bmp.
sergey slezkin

thanks sergey - "i got it!!"
for anyone interested, here is the code which created a bmp that photoshop liked. if anyone has improvements, i'm listening.
///////////////////////////////////////////////////////////////////////////////
int cdwgdirect::extractthumbnail(cstring &csoutfile)
{
int iret = 0;
odthumbnailimage odimage;
try
{
oddbgetpreviewbitmap(svcs.createfile( m_pdb->getfilename()), &odimage );
}
catch(...)
{
return iret;
}
if (! odimage.hasbmp())
return iret;
if( csoutfile.getlength() < 4
|| stricmp(csoutfile.right(4), ".bmp") )
csoutfile += ".bmp";
bitmapinfoheader *pheader;
pheader = (bitmapinfoheader *)(odimage.bmp.begin() );
if(!pheader)
return iret;
//found this algorythm in msdn
int bisizeimage = ((((pheader->biwidth * pheader->bibitcount) + 31) & ~31) >> 3) * pheader->biheight;
if(!bisizeimage)
return iret;
handle hf = createfile(csoutfile,
generic_read | generic_write,
(dword) 0,
null,
create_always,
file_attribute_normal,
(handle) null);
if (hf == invalid_handle_value)
return iret;
//use num colors for offset to bits calculation
int ncolors = 1 << pheader->bibitcount;
// fill in the fields of the file header
bitmapfileheader hdr;
hdr.bftype = ((word) ('m' << 8) | 'b'); // is always "bm"
hdr.bfsize = bisizeimage + sizeof( hdr );//globalsize (hdib) + sizeof( hdr );
hdr.bfreserved1 = 0;
hdr.bfreserved2 = 0;
hdr.bfoffbits = (dword) (sizeof( hdr ) + pheader->bisize +
ncolors * sizeof(rgbquad));
// write the file header
dword dwtmp;
writefile(hf, (lpstr)&hdr, sizeof(hdr), (lpdword) &dwtmp, null);
// write the dib header and the bits
writefile(hf, (lpstr) pheader, odimage.bmp.length(), (lpdword) &dwtmp, null);
iret = closehandle(hf);
return(iret);
}
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】different vectorization of same file on windows and mac yang686526 DirectDWG 0 2009-05-04 07:29 PM
【转帖】dd1.1204 cant load the attached file yang686526 DirectDWG 0 2009-05-04 07:05 PM
【转帖】creating a sat file out of dxf solid file yang686526 DirectDWG 0 2009-05-04 06:47 PM


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


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