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

support for non-bmp images in dwf files
support for non-bmp images in dwf files
i am trying to raster jpg image embedded in .dwf file. the dwfimagemanager sends in odmemorystream to exrastermodule::loadrasterimage(odstreambuf *pbuf). the function handles images with type = 19778 (!!!)(.bmp). but i couldn't load jpg image. what is this type number for and how do i handle other formats. i can successfully export .dwf to .dwg and load the jpg images since .dwg module sends in the filename to exrastermodule::loadrasterimage(const odstring &filename) and it handles all image formats. is there anyway i can do similar with .dwf module or is there any otherway to interpret the odmemorystream buffer to handle file formats other than .bmp
thanks.
first, i agree that "type = 19778 " is not graceful way to check if first 2 bytes are "bm" sequence starting bitmap file.
raster services are placed to examples folder and are available as source code because handling all possible raster formats is enomous job and most developers have some 3-d party raster library available.
loadrasterimage(filename) has implementation using jpeg-6b and snowbound libraries.
lt was possible to implement loadrasterimage(odstreambuf) creating a temporary file and calling filename version but some raster libraries may have more efficient way to do it via call-back functions reading the data for example.
also we'll check if dwfimport realy needs to load raster file as gi image. probably it would be possible to create a raster file, imagedef and image entity without parsing the raster data.
sergey slezkin
data format for odstreambuf in loadrasterimage(odstreambuf)
first of all, thank you very much for prompt reply.
is there anyway to find out type of image the odstreambuf in loadrasterimage(odstreambuf) is referring to, so that i can load and use right library to display the image? or any other way around to display images other than bmp?
thanks
inside loadrasterimage(odstreambuf) where is no additional information on image format. usually first characters in the stream indicate it.
dwf import before calling loadrasterimage(odstreambuf) has this information.
i want to check if it's possible simply save the image file (contents of odstreambuf) without parsing it by raster services.
sergey slezkin
sergey,
did you determine if "it's possible simply save the image file (contents of odstreambuf) without parsing it by raster services." i'm curious about this too...
tyler
dwf import uses raster services to load image for immediate display only. having gi image loaded or not, does not affect file contents. if user raster services do not support given image type, import works just as if there were no raster services. that is - the image will be saved and inserted in dwg, but, naturally, it will not be rendered by the importing application.
if you need not to display the image right away, you may unload raster services module and the image will be saved and inserted in dwg, without parsing. or you can just return null pointer for unknown raster type from your raster services module.
raster type is usually determined by first bytes (signature) of the file.
vladimir
last edited by vkalinin; 29th june 2005 at 07:49 amfff">.
hi,
here is what i did to make it simple and see whats in the odstreambuf:
code:
odgirasterimageptr exrastermodule::loadrasterimage(odstreambuf *pbuf)
{
cfile tempfile("tmp.jpg", cfile::modecreate | cfile::modereadwrite | cfile::typebinary);
tempfile.write(pbuf, pbuf->length());
tempfile.close();
}
included image is a .jpg image, the sample file() is attached.
when i try to open the saved jpeg file using image editor, it can not open that file.
attached files (358.2 kb, 9 views)

one side note to be added in above post:
converting the dwf to dwg and then, from dwg saving jpg file and opening it with image editor works.
quote:
originally posted by jaisam
hi,
here is what i did to make it simple and see whats in the odstreambuf:
code:
odgirasterimageptr exrastermodule::loadrasterimage(odstreambuf *pbuf)
{
cfile tempfile("tmp.jpg", cfile::modecreate | cfile::modereadwrite | cfile::typebinary);
tempfile.write(pbuf, pbuf->length());
tempfile.close();
}
included image is a .jpg image, the sample file() is attached.
when i try to open the saved jpeg file using image editor, it can not open that file.
that is strange, to say the least. what is the image length in both cases?
vladimir
in both cases the buffer length read from file is 188900 bytes.
could you please attach the image saved by your raster services?
vladimir
images
required images are attached. remove .txt extension from dwf_saved filename. the forum identifies it as invalid jpg and wouldn't allow me to attach.
attached images (184.5 kb, 9 views)
attached files (184.5 kb, 4 views)

is there any updates on this issue? or any suggested fixes to get the correct image file from .dwf?
thanks.
i checked that dwfimport creates image files and references to them in dwg correctly even if raster services are unable to load the raster image (or if where is no raster services at all.) so you need not implement them. i checked this in odamfcapp sample.
note that .jpg file is written not at import moment but at the same time you write .dwg file.
the jpg you saved obviously is not a jpeg file. i think that in your code odstreambuf * pbuf is simply casted to char* and you write to file not stream contents but a piece of memory starting at the begining of odstreambuf object.
to get stream contents you need to call getbytes().
sergey slezkin
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】no lineweights on bmp-expor yang686526 DirectDWG 0 2009-05-06 06:34 PM
【转帖】merging dwfdwg files yang686526 DirectDWG 0 2009-05-06 05:43 PM
【转帖】export to dwf v6.0 not working in oddwfexportex - dd rel 2.2 yang686526 DirectDWG 0 2009-05-05 10:27 AM
【转帖】dwf printing problems yang686526 DirectDWG 0 2009-05-05 07:51 AM
【转帖】dwf exportimport raster images yang686526 DirectDWG 0 2009-05-04 08:21 PM


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


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