png images in user defined points can not display

Jan 12, 2012 at 2:57 AM

Is there any way to use png images instead of bmp images for displaying user defined points in my shapefile ?

Only  bmp images with 256 color is working which is not sharp enough.

Is there a bug or error config setting?

Please help if anybody Succeed in using png images. I am using VS2008,C#


               MapWinGIS.Image imgObj = new MapWinGIS.Image();


                //bool bResult = imgObj.Open("..\\data\\camera_mount.png", MapWinGIS.ImageType.IMG_FILE, false, null);

                bool bResult = imgObj.Open(this.tbImgFileName.Text, MapWinGIS.ImageType.USE_FILE_EXTENSION, true, null);

                Debug.Assert(true == bResult);

                //imgObj.TransparencyColor = (uint)ColorTranslator.ToOle(Color.White);
                //imgObj.UseTransparencyColor = true;

                axMap1.set_ShapeLayerPointSize(m_iPointLayerIndex, iPointSize);

                axMap1.set_ShapeLayerPointType(m_iPointLayerIndex, MapWinGIS.tkPointType.ptUserDefined);
                axMap1.set_UDPointType(m_iPointLayerIndex, imgObj);

Jan 20, 2012 at 12:09 AM

Hi liaosl88,

You can just use imgObj.Open(yourimage.png, MapWinGIS.ImageType.USE_FILE_EXTENSION, true, null)

I don't have the code with me but it works. The transparency is enabled by default, so to make use of it, make sure your PNG file has an alpha channel.

Jan 29, 2012 at 11:41 PM

Thank Jan, I has already used your suggestion, but it cann,t work..  Is there some special setting?

Jan 30, 2012 at 8:01 AM

Hi liaosl88,

My code is something like this, using MapWinGIS v4.8 Final:

Dim MyImg As New MapWinGIS.Image
MyImg.Open(C:\\data\camera_mount.png", MapWinGIS.ImageType.USE_FILE_EXTENSION, True)
ShpFile.DefaultDrawingOptions.PointType = MapWinGIS.tkPointSymbolType.ptSymbolPicture
ShpFile.DefaultDrawingOptions.Picture = MyImg

You do not need to set the LayerPointSize. If you want to resize the Image, use

ShpFile.DefaultDrawingOptions.PictureScaleX = 0.5
ShpFile.DefaultDrawingOptions.PictureScaleY = 0.5
This will reduce the img size by half.