![]() |
【转帖】reading embedded rasters
reading embedded rasters
reading embedded rasters i am importing hybrid dwf files (contain raster and vector entities) and then trying to read the raster data from them. when i look in the debugger i can see that the oddbrasterimage contains an embeddedraster which contains the extension, name and data for the image. however, i cannot figure out how to access the data. when i access the odgirasterimage i can get the pixelwidth and pixelheight just fine, but colordepth is zero. what is worse is that when i use scanline to access the data an exception is thrown. how does one read an embeddedraster? here is the code i am using that does not work (eliminating the stuff not dealing with reading the file): code: int readembeddedimage(odgirasterimageptr praster) { long raswidth = praster->pixelwidth(); // works long rasheight = praster->pixelheight(); // works long bitsperpixel = praster->colordepth(); // returns zero if (bitsperpixel == 0) bitsperpixel = 24; long scanlinesize = praster->scanlinesize(); // returns zero unsigned char *psclns = new unsigned char[raswidth*3]; for (long ln = 0; ln < rasheight; ln++) { praster->scanlines(psclns, ln); // dies here unsigned char *pscan = psclns; for (long wd=0; wd < raswidth; wd++) { clr.blue = *pscan++; clr.green = *pscan++; clr.red = *pscan++; if ((clr.blue != 255) || (clr.green != 255) || (clr.red != 255)) cout << clr.blue << "/" << clr.green << "/" << clr.red << endl; } } embeddedimagedef is declared in imports\dwfimport\source\embeddedimagedef.h you may use it directly, to access image data stream. this is a dirty hack of course. to use scanlines() etc. you have to implement a raster service that will load the raster from stream and convert it to a bitmap. (look at extensions\exservices\exgirasterimage.cpp exrastermodule::loadrasterimage()) vladimir |
所有的时间均为北京时间。 现在的时间是 10:02 PM. |