mapWnd.Width = 512;
mapWnd.Height = 512;
However, this is not entirely correct because the width and height of the MapWindow object include the Windows border and title bar as shown in the example screen shot below.
When you do a snap shot of the map window by selecting Edit > Snapshot, an image of the map view is created in the Windows clipboard. The map view image would have a width and height a little less than the width and height you set earlier e.g. 504 pixels by 489 pixels.
To get a map view image with the exact dimensions you want, you will have to add the border width and title bar height to the MapWindow object's width and height properties. An example code listing is shown below.
MapviewLib.GMMapView mview = null;
double xlo = 0, ylo = 0, zlo = 0, xhi = 0, yhi = 0, zhi = 0; //world
int pixelXlo = 0, pixelYlo = 0, pixelXhi = 0, pixelYhi = 0; //pixels
int mviewWidth, mviewHeight; //map view dimensions
//Set an initial desired width and height, e.g. 512x512
mapWnd.Width = 512;
mapWnd.Height = 512;
//Get the mapview object in the map window
mview = (MapviewLib.GMMapView)mapWnd.MapView;
//Get the map view object's MBR in real world coordinates
mview.GetRange(ref xlo, ref ylo, ref zlo, ref xhi, ref yhi, ref zhi);
//Convert the real world coordinates to screen pixels
mview.WorldToWindow(xlo, ylo, zlo, ref pixelXlo, ref pixelYlo);
mview.WorldToWindow(xhi, yhi, zhi, ref pixelXhi, ref pixelYhi);
//Calculate the map view objects width and height
mviewWidth = Math.Abs(pixelXhi - pixelXlo);
mviewHeight = Math.Abs(pixelYhi - pixelYlo);
//Adjust the map window object's dimensions by adding
//in the border and title bar's dimensions
mapWnd.Width = (mapWnd.Width - mviewWidth) + mapWnd.Width;
mapWnd.Height = (mapWnd.Height - mviewHeight) + mapWnd.Height;
After this adjustment, the snap shot image will have the correct desired dimensions.
god bless you. intergraph information on the internet is absolutely rare, unhappyly
ReplyDelete