This project is read-only.

Export Symbols (Point Shape) into Image/Bmp

Jan 31, 2013 at 7:47 AM
Hi, I have set a DrawingOptions for a point shape like below.
    oShapeFile(2).Categories.Item(shpIndex).DrawingOptions.PointType = MapWinGIS.tkPointSymbolType.ptSymbolStandard
      oShapeFile(2).Categories.Item(shpIndex).DrawingOptions.PointShape = MapWinGIS.tkPointShapeType.ptShapeFlag
      oShapeFile(2).Categories.Item(shpIndex).DrawingOptions.FillColor = ColorTranslator.ToWin32(Color.AliceBlue)
    oShapeFile(2).Categories.Item(shpIndex).DrawingOptions.PointSize = 20                                             'point size
    oShapeFile(2).Categories.Item(shpIndex).DrawingOptions.FillVisible = True                                        'show the fill
How to export the Point Shape/Symbols into image?

I'm trying to create a map legend in a Picture control, and need this Point Shape drawn into the picture control.
Jan 31, 2013 at 4:15 PM
You can have a look at the legend control of MapWindow. That is doing as you request.
You can find the source code here: http://svn.mapwindow.org/svnroot/MapWindow4Dev/MapWindow/

Feel free to post your solution here again ;)

Paul
Feb 1, 2013 at 2:43 AM
Hi Paul,

Thank you for pointing that out.
Yes I have noticed the symbol preview panel in legend control of MapWindow, and that's exactly what I want.
However after trying to check properties/methods in MapWinGIS, I can't find how to get it.

I have tried to get the MapWindow project only source code, but still can't figure out how the legend control works (get some errors because source code incomplete).
I'm not an .NET developer (I am an ABAPer) and just have basic knowledge of visual studio.
Currently I'm trying to get all MapWindow4Dev source code and not sure if I can find what I'm looking for.
If someone can point me to the Layer Properties or Point Style dialog form source code will be helpful.

Thanks!
Feb 1, 2013 at 3:21 PM
The code is not very optimized so I hope you can understand it.
Look for the method DrawShapefileCategories in http://svn.mapwindow.org/svnroot/MapWindow4Dev/MapWinInterfaces/Legend.cs that should give you some idea how to do this.

Basically what you do is loop through the categories and create a point, square or line based on the settings of that category.

Paul
Feb 4, 2013 at 5:16 AM
Hi Paul,

Thank you very much!
I will post my solution here once I figure it out.
Unfortunately I'm being interrupted by another priority task and hopefully I can continue with this next week.

Thanks!
Feb 7, 2013 at 7:13 AM
Hi,
managed to spend some times on this
after a frustrating moment because missed one line of code (graph.ReleaseHdc(hdc))
here is the solution I find out :)
    Dim bmp As New Bitmap(100, 100)
    Dim graph As Graphics = Graphics.FromImage(bmp)
    Dim hdc As IntPtr = graph.GetHdc()

    Dim opt As MapWinGIS.ShapeDrawingOptions
    opt = oShapeFile(2).Categories.Item(shpIndex).DrawingOptions
    opt.DrawPoint(hdc, 1, 1)
    graph.ReleaseHdc(hdc)

    bmp.Save("c:/test.bmp")
Thanks!