![]() |
【转帖】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 |
所有的时间均为北京时间。 现在的时间是 12:08 PM. |