Hi,
I'm programming with pure MDL (it's a huge application not migrated yet to C++) over MicroStation and Bentley Map SS4.
I need to create programmatically an image file (JPEG, BMP or similar) from the default model of a DGN, but without open the DGN with mdlSystem_newDesignFile.
I know how to to do it when the DGN is open (capturing the screen, printing to JPEG plot driver, etc), but now I need to do ii in that way.
It doesn't matter if the file image is small in size or the quality is not optimal, because I need the image to embed it in a sheet model for plotting.
I've tried the following (via thumbnail) and I can get the JPEG file, but the contents of this file is incorrect (see image below).
int estat; char fileName[MAXFILELENGTH], fJpg[MAXFILELENGTH]; byte *imageBufferP=NULL; int imageSize; byte redPalette[256], grnPalette[256], bluPalette[256]; int paletteSize, colorMode; Point2d size; strcpy (fileName, "C:\\dgn\\MapIndex.dgn"); strcpy (fJpg, "C:\\dgn\\MapIndex.jpg"); // Open the thumbnail of the selected dgn. estat = mdlSystem_openFileThumbnail (NULL, NULL, NULL, NULL, fileName, &imageBufferP, &imageSize); if (estat == SUCCESS) { // mdlImage_getExportSupport (&colorMode, NULL, NULL, NULL, NULL, NULL, IMAGEFILE_JPEG); mdlImage_getScreenPalette (redPalette, grnPalette, bluPalette, &paletteSize, statedata.current.screenNumber); size.x = 300; size.y = 300; mdlImage_createFileFromBuffer (fJpg, IMAGEFILE_JPEG, colorMode, &size, imageBufferP, IMAGEFORMAT_BitMap, NULL, NULL, NULL, paletteSize, 0, NULL); // Clear buffer. if (imageBufferP) { mdlSystem_freeFileThumbnail (&imageBufferP); } }
Please, any hint to solve this question?
Thanks a lot for your help.
Toni
Toni P. said:How can I export ... file without opening the file?
In general, the answer is: You can't. Whatever the file — DGN or Word or Excel or something else — you must open the file to be able to read its contents.
Toni P. said:I'm programming with pure MDL
The question you may be asking is: How do I open a DGN file and process it without showing any graphics to the user? That is, you want to batch-process a DGN file without opening a graphics window.
You can do that in MDL by writing an MS_INITAPP program. The key is to start your MDL app. using the -wa command line switch. Write your MdlMain() function to detect that you have been started as an MS_INITAPP program. Your code will run in MicroStation, but MicroStation will not display graphics unless you use mdlSystem_enterGraphics().
MS_INITAPP
-wa
MdlMain()
mdlSystem_enterGraphics()
You must nevertheless use mdlSystem_newDesignFile() to open a DGN file! I believe that there is an example of an MS_INITAPP in the SDK examples.
mdlSystem_newDesignFile()
Regards, Jon Summers LA Solutions
Answer Verified By: Toni P.