Can someone help me please for the relevant Java code of the below C# function.
I am having trouble to pass the first argument i.e. “hDC” for ISymbol.setupDC method. For variable “g”, I am using Java “java.awt.Graphics2D” class as an equivalent of C# “System.Drawing.Graphics”.
private static Image PointSymbolToImage(ISymbol symbol, Size imageSize) {
double x = (imageSize.Width / 2);
double y = ((imageSize.Height - 1) / 2);
IPoint point = new PointClass();
point.PutCoords(x, y);
Bitmap bmp = new Bitmap(imageSize.Width, imageSize.Height);
Graphics g = Graphics.FromImage(bmp);
symbol.SetupDC(g.GetHdc().ToInt32(), null);
try {
symbol.Draw(point);
}
catch (System.Exception ) {
}
symbol.ResetDC();
g.Dispose();
return (Image) bmp;
}
Esri Development Centers Esri Technical Support ArcObjects SDK ArcObjects.NET ArcGIS Runtime SDK for Java
Hi Ranga,
you can obtain the hDC from the active viewer of whatever control (MapControl or GlobeControl) you are working with
For MapControl:
IMapControl.getActiveView.getScreenDisplay.geHDC
For GlobeControl:
IGlobeControl.getGlobeDisplay.getActiveViewer.getHDC
Hi Kwasi,
Thanks for your response.
My application has no UI, it's a back end batch job, which should generate the images from ISymbol and save them to the disk.