几何尺寸与公差论坛------致力于产品几何量公差标准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)
-   -   【转帖】byte data from a oddbrasterimage (http://www.dimcax.com/hust/showthread.php?t=15314)

yang686526 2009-05-04 05:14 PM

【转帖】byte data from a oddbrasterimage
 
byte data from a oddbrasterimage
byte data from a oddbrasterimage
hi
i'm trying to extract the byte data from a raster contained in a dwg file. the image is being passed to me as a oddbrasterimage, but i can't see any obvious way to get access to the byte data.
any clues, anyone?
thanks
peter.
see examples\odreadex\exprotocolextension.cpp, 1445
dumprasterimagedef()
vladimir
byte data from a oddbrasterimage
hi
yes i saw that example, thanks. it describes how to get all sorts of metadata about the image ie size, resolution, clipping window etc, but i still can't see how to get access to the byte data?
thanks,
peter.
there is a file name in metadata.
image is not stored inside the drawing.
vladimir
you also can get the contents of raster file using odgirasterimageptr oddbrasterimagedef::image().
it loads and converts the raster to bmp like data using rxrasterservices.drx.
its default implementation supports only bmp and jpg. but you can use your own one which supports other raster formats. extensions/exservices/exgirasterimage besides default implementation contains code using snowbound library.
sergey slezkin
hi
i'm still having trouble getting the image bits out from a oddbrasterimage.
some context:
i'm handling a database created by your dwf7import library from a dwf file containing embedded images. if i call database::write on the database created by the library i can see that jpeg and png images are being written to the file system. this makes me confident that i have everything i need compiled and linked to get image data, including the jpeg library and exgirasterimage.
i have confirmed that the raster is in the raster dictionary, but calling oddbrasterimagedef::sourcefilename() returns a empty string. therefore the raster data must be present in the database itself.
i've tried calling odgirasterimageptr oddbrasterimagedef::image(), and i can get the width and height of the image from this.
odgirasterimage::scanlines() returns null, as does casting it to a odexgirasterimageptr and calling bits().
what am i doing wrong?
peter.
look at the function extensions\exservices\exgirasterimage.cpp
code:
odgirasterimageptr exrastermodule::loadrasterimage(odstreambuf *pbuf)
when imported dwf is not yet saved, this function is used to load images.
if you use jpeg6b (not sb), then this function won't load image.
vladimir
i'm confused. how does this apply to handling a oddbrasterimage?
where do i get the odstreambuf from and what is it reading from?
peter.
image is stored as binary stream when read from dwf. (that's the reason why file name is null, until the file is saved). to get gi interface from that stream, loadrasterimage() is called.
raster handling functions are user supplied. (by implementing a module with a name equal to rx_raster_services_appname)
a sample implementation is available in extensions\exservices\exgirasterimage.cpp
dd internally calls
code:
odrxrasterservicesptr prassvcs = odrxdynamiclinker()->loadapp(rx_raster_services_appname);
prassvcs->loadrasterimage(
vladimir
ok, so how do i get a odstreambuf stream from a oddbrasterimage?
thanks
peter.
actually, i've just seen a getcompounddocument(odstreambuf& streambuf) method in odoleitemhandler. so i think that will do what i'm wanting.
thanks,
peter.
last edited by peter.aberline@cadcorp.com; 10th october 2007 at 06:42 amfff">.
sorry, i'm getting myself tied up in knots here. i've been working on handling embedded rasters as oddbole2frame objects as well as oddbrasterimage's and i mistook the two when i made my last post.
i don't think i can use odoleitemhandler to get the stream as i've only got a oddbrasterimage. so my questions still stands, how do i go from oddbrasterimage to odstreambuf?
thanks
peter.
ole is irrelevant in the case.
you should either implement exrastermodule::loadrasterimage, and then take the way that sergey suggested, or save the drawing to some temp location, and obtain the image file name from the image descriptor.
vladimir
hi
all i need is the raw bits from the image, without any decoding/uncompression.
shouldn't the default, oda supplied implementation of exrastermodule::loadrasterimage be able to give me this for a jpeg based oddbraster at the very least? i have jpeg-6b linked in. i don't understand why i need my own implementation of exrastermodule::loadrasterimage.
using the oda implementation i always get an empty bits set back from:
odgirasterimageptr ptrimagedata = ptrimgdef->image();
assert(!ptrimagedata.isnull());
odexgirasterimage& bitmap = (odexgirasterimage&)*ptrimagedata.get();
oduint32 bitsize = bitmap.bitdatasize();
// bitssize is 0 here.
odbinarydata& bindata = bitmap.bits();
// bindata is empty here.
thanks
peter.
last edited by peter.aberline@cadcorp.com; 11th october 2007 at 02:59 amfff">.
hi
has there been any progress with this query?
thanks
peter.


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