ThinkGeo.com    |     Documentation    |     Premium Support

PNG rendering

Hi Guys,


Anyone know how to get a PNG file displayed without being antialiased or "fiddled with"?


Below are two images, the first is a ThinkGeo image and the second the same PNG from Paint.  The ThinkGeo image looks fuzzy as if it had been antialiased.


Screen shot was with CompositingQuality Default,DrawingQuality HighSpeed, SmoothingMode HighSpeed and TextRenderingHint SingleBitPerPixelGridFit.


I know the two images look fairly similar but when displayed at 2560*1600 the ThinkGeo image becomes quite tiring on the eyes.








 


John,


I think that's because the png is stretched. I tried the same png file and make it drawing on map without any stretching, it looks the same as displayed in Windows Paint.



Here is the demo how to show the png without any stretching. You can see as the png is 277*197, I made the control size to 277 * 197 and made the extent's with and height with the ratio 277:197.


Let me know if you have any issues.


Thanks,


Ben




561-TestPNGDisplaying.zip (38.6 KB)

Hi Ben, 
  
 Thanks for that, that gives me a clue, that its me thats wrong.  The problem I am stuggling with is that the actual PNG size is 3199 x 4877 so setting the extent is not an option, I need to calculate and set the scale so that we get true resolution, any thoughts? 
  
 Regards 
  
 John




 

 


John,


Here is a small demo how to deal with that. 2 notes here: 1st, the boundingbox of the png layer should have the same ratio of the image's width and height, so for your case it should be 3199:4877; 2nd, I plus 1 on the width and height to balance the internal calculation difference (the map will modify the input bounding box according to the control's width and height as its new bounding box, maybe there has some calculation difference, we will have a look at that) I think. You may also need some for your image.


Let me know what's the result.


Thanks,


Ben


 



562-TestPNGDisplaying2.zip (39.2 KB)

I work Thinkgeo Desktop Edition  evalution version in C#. 
 And I use  png image on the map.For this work I use DrawCore.When I pan map,I lost same image.This events hapen,when  centerpoint of  image not location  on map.For example  in  1.png have image. When I pan map this image is lost (2.png). 
  
 This is my code example: 
 //Drawcore  class worldimage style 
 namespace shape_version 
 { 
     class Shekiller : Style 
     { 
 … 
 … 
 protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas,Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers) 
         { 
             if (image != null) 
             {                 
                 double canvasWidthMeter; 
                 double canvasHeightMeter; 
                 double imageWidthMeter  = imageWorldWidth;                 
                 double imageHeightMeter = imageWorldHeight; 
                 DistanceUnit fromUnit = DistanceUnit.Meter; 
                 if (mapUnit == GeographyUnit.Meter) fromUnit = DistanceUnit.Meter; 
                 canvasWidthMeter  = canvas.CurrentWorldExtent.Width;               
                 canvasHeightMeter = canvas.CurrentWorldExtent.Height; 
                 float widthSize = (float)((imageWidthMeter * canvas.Width) / canvasWidthMeter); 
                 float heightSize = (float)((imageHeightMeter * canvas.Height) / canvasHeightMeter); //fontSize             
                 foreach (Feature feature in features) 
                 { 
                     WellKnownType shapeWellKnownType = feature.GetWellKnownType(); 
                     if (shapeWellKnownType == WellKnownType.Point || shapeWellKnownType == WellKnownType.Multipoint) 
                     {                       
                         PointShape point = new PointShape(feature.GetWellKnownBinary()); 
                         canvas.DrawWorldImage(image, point.X, point.Y ,widthSize,heightSize,DrawingLevel.LabelLevel, 0, 0, rotateAngle);                       
                     } 
                 } 
             } 
             System.GC.Collect(); 
         } 
  
 //DRawcore 
     private void Window_Loaded(object sender, RoutedEventArgs e) 
         { 
             wpfMap1.MapUnit = GeographyUnit.Meter; 
             wpfMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 233, 232, 214));             
              
    
             ShapeFileFeatureLayer evler_route = new ShapeFileFeatureLayer(@"…\Data\ESRI\polygon.shp"); 
             evler_route.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Beige,                  GeoColor.FromArgb(100, GeoColor.StandardColors.Chocolate)); 
             evler_route.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; 
 … 
             ShapeFileFeatureLayer yollar_shp = new ShapeFileFeatureLayer(@"…\Data\ESRI\polyline.shp"); 
             yollar_shp.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(LineStyles.LocalRoad3); 
             yollar_shp.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; 
             if (yollar_shp.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.OuterPen.Width > 2) 
             { 
                 yollar_shp.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.InnerPen.Width -= 9; 
                 yollar_shp.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.OuterPen.Width -= 9; 
             } 
     … 
             ShapeFileFeatureLayer qala = new ShapeFileFeatureLayer(@"…\Data\ESRI\Qala.shp"); 
             qala.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(LineStyles.LocalRoad4); 
             qala.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; 
              
     … 
             LayerOverlay staticoverlay = new LayerOverlay(); 
             staticoverlay.Layers.Add("EVLER_R", evler_route); 
             staticoverlay.Layers.Add("Yollar_shp", yollar_shp); 
             staticoverlay.Layers.Add("Qala", qala); 
             wpfMap1.Overlays.Add("Layerler", staticoverlay); 
 … 
  
  
             InMemoryFeatureLayer[] shipInMemoryFeatureLayer = new InMemoryFeatureLayer[29]; 
             LayerOverlay cemi = new LayerOverlay(); 
             shipInMemoryFeatureLayer[0] = new InMemoryFeatureLayer();             
             geoImage[0] = new GeoImage(@"…\Data\image_web\qalalar.png"); 
             double en_1 = targetshape_qala.GetBoundingBox().LowerRightPoint.X - targetshape_qala.GetBoundingBox().LowerLeftPoint.X; 
             double uz_1 = targetshape_qala.GetBoundingBox().UpperLeftPoint.Y - targetshape_qala.GetBoundingBox().LowerLeftPoint.Y; 
 !!! 
             Shekiller  shekil_transfer[0] = new Shekiller(geoImage[0], GeographyUnit.Meter, en_1, uz_1, DistanceUnit.Meter, 4); 
 !!! 
            
             // shipInMemoryFeatureLayer[0].ZoomLevelSet.ZoomLevel01.CustomStyles.Clear();             
             shipInMemoryFeatureLayer[0].ZoomLevelSet.ZoomLevel01.CustomStyles.Add(customimage_style); 
             shipInMemoryFeatureLayer[0].ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; 
             shipInMemoryFeatureLayer[0].InternalFeatures.Clear(); 
             shipInMemoryFeatureLayer[0].InternalFeatures.Add(new Feature(new PointShape(targetshape_qala.GetBoundingBox().GetCenterPoint().X,            targetshape_qala.GetBoundingBox().GetCenterPoint().Y))); 
             cemi.Layers.Add("qalwpfMap1.Overlays.Add("Layerler", staticoverlay); 
             wpfMap1.Overlays.Add("Layerler", staticoverlay); 
 … 
 wpfMap1.ZoomLevelSnapping = ZoomLevelSnappingMode.None; 
             wpfMap1.CurrentExtent = ExtentHelper.GetDrawingExtent(new RectangleShape(400843.093380, 4469345.625271, 401354.378890, 4468739.821959), 1166,812);               
  
 my picture 1.png     boxca.com/85j2o27byg13/1.PNG.html 
  
 my picture 2.png   boxca.com/m0f6mfffnl2s/2.PNG.html 


Serxan,


Welcome to MapSuite's world.


I have tried to recreate this issue, but I can not make it.


The attachement is the sample application I create from your code, the original code can not be compiled, so I updated some of them, but I can not run because of lacking some of the necessary code.


Please update the sample application and attached your data if they're needed to make it can recreate your problem.


Thanks


James 



1857-PngTest.zip (9.81 KB)