Picture 1: Using Screen Capture of Micro Station in Built Tool, We Got This Quality of Image

Total Page:16

File Type:pdf, Size:1020Kb

Picture 1: Using Screen Capture of Micro Station in Built Tool, We Got This Quality of Image

Picture 1: Using Screen capture of Micro Station in built tool, we got this quality of image.

Picture 2: Using the below given code chdlg.mc of Bentley, we are able to get this quality of image. (Quality of image is lost when compared to the picture 1). How to retain the same quality of image ???.

I tried:

1) Using different parameters of mdlImage_extMapToRGB with mdlImage_createFileFromRGB.

2) Using different parameters of mdlImage_extCreateFileFromMap

Parameters include Image file type, Image colour mode, compression types ..etc

/*------+ | | chdlg.mc | +------*/ /*------+ | | STATUS: WORKING | DATE: 1/28/2002 2:02:24 PM | | This example illustrates how to capture the screen before file closes. | +------*/ /*------+ | | Include Files | +------*/ #include #include #include #include #include #include #include

#include #include #include #include #include #include #include #include #include #include #include #include #include #include

/*------+ | | Public variables | +------*/ /*------+ | | External variables | +------*/ /*------+ | | Function Definitions | +------*/ /*------+ | | Function Declarations | +------*/ /*------+ | | name exitApplication | | author BSI 12/1998 | +------*/ Private void exitApplication ( boolean silently /* => Unload this application silently */ ) { /*------Queue a command to unload the application with/without displaying a notification message. ------*/ mdlDialog_cmdNumberQueue (FALSE, (silently) ? CMD_MDL_SILENTUNLOAD : CMD_MDL_UNLOAD, mdlSystem_getCurrTaskID (), TRUE);

/* Start the default command */ mdlState_startDefaultCommand (); }

/*------+ | | name openResources | | author BSI 12/1998 | +------*/ Private void openResources ( void ) { RscFileHandle rscH; /* A resource file handle */

if (mdlResource_openFile (&rscH, NULL, RSC_READONLY) != SUCCESS) { mdlOutput_error ("Unable to load Resource File."); } }

/*------+ | | name buildOutFileName | | author BSI 1/2001 | +------*/ Public int buildOutFileName ( char *fileNameWithPath, /* <= File name with full path size to MAXFILELENGTH*/ char *extension /* => File Extension to append size to MAXEXTENSIONLENGTH*/ ) { char filename[MAXFILELENGTH], device[MAXDEVICELENGTH], dir[MAXDIRLENGTH], currentExt[MAXEXTENSIONLENGTH];

/* Obtain the name of the current deign file */ mdlFile_parseName (tcb->dgnfilenm, device, dir, filename, currentExt); /* Build new file with current DGN name and specified extension */ mdlFile_buildName (fileNameWithPath, device, dir, filename, extension);

/* Verify successful build of file name with path */ if (*fileNameWithPath == NULL) { return !SUCCESS; }

return SUCCESS; }

/*------+ | | name saveDLG | | author BSI 01/2002 | +------*/ void saveDLG ( char *filenameP, /* => name of file */ int state /* => SYSTEM_NEWFILE_CLOSE, SYSTEM_NEWFILE_COMPLETE */ ) { byte *inputMap; byte redMap [256]; byte grnMap [256]; byte bluMap [256]; Point2d palletSize; MSWindow *windowP = NULL; MSWindow *lastWindowP = NULL; DialogBox *dlgP = NULL; Rectangle rectangle; char fileName [MAXFILELENGTH +1]; int size = 0; int fileType = 0;

if (state == SYSTEM_NEWFILE_CLOSE) {

/* Prompt user to save or not */ if (mdlDialog_openMessageBox (DIALOGID_MsgBoxYesNo, "Do you want to save?", MSGBOX_ICON_QUESTION) == ACTIONBUTTON_YES) {

/* Get last view */ lastWindowP = mdlWindow_viewWindowGet (tcb->lstvw); mdlWindow_maximize (lastWindowP);

/* Bring window to front */ mdlWindow_toFront (lastWindowP);

//lastWindowP = mdlDialog_find (DIALOGID_MsgBoxYesNo, NULL); mdlWindow_windowEventsProcessAll();

/* Close the tools settings bialog box */ dlgP = mdlDialog_find (DIALOGID_ToolSettings, "MGSHOOK"); mdlWindow_hide (dlgP, FALSE, FALSE);

/* Update view */ mdlView_updateSingle (tcb->lstvw);

/* Get the window rectangle */ windowP = mdlWindow_viewWindowGet (tcb->lstvw); mdlWindow_contentRectGetGlobal (&rectangle, windowP);

/* Rectangle to capture. */ palletSize.x = rectangle.corner.x - rectangle.origin.x + 1; palletSize.y = rectangle.corner.y - rectangle.origin.y + 1;

/* Capture the screen */ mdlImage_captureScreenMap (&inputMap, &rectangle, statedata.current.screenNumber);

/* Get the screen palette */ mdlImage_getScreenPalette (redMap, grnMap, bluMap, &size, tcb- >lstvw);

/* Build file name */ buildOutFileName (fileName, "jpg");

// Get file type fileType = mdlImage_typeFromExtension (fileName);

// Convert to an RGB mdlImage_extMapToRGB (&inputMap, /* <= image buffer (RGB) */ inputMap, /* => image map */ &palletSize, /* => image size */ redMap, /* => red palette entries */ grnMap, /* => green palette entries */ bluMap, /* => blue palette entries */ FALSE, /* => pack bytes (run length encode) */ NULL); /* => stop function (or NULL) */

// Create the file mdlImage_createFileFromRGB (fileName, /* => name of file */ fileType, /* => type of file (see image.h) */ COLORMODE_RGB, /* => color mode (see image.h) */ &palletSize, /* => size of image */ inputMap, /* => RGB values for each pixel */ NULL); /* => stop function (or NULL) */

/* Show the tools settings. */ mdlDialog_show (dlgP);

/* Free memory */ if (inputMap) free (inputMap); }

} }

/*------+ | | name main | | author BSI 01/2002 | +------*/ Private int main ( int argc, /* => Number of arguments passed in argv */ char *argv[] /* => Array of pointers to arguments */ ) { /* Open our application for use with the Resource Manager */ openResources ();

mdlSystem_setFunction (SYSTEM_NEW_DESIGN_FILE, saveDLG);

return SUCCESS; }

Recommended publications