ThinkGeo.com    |     Documentation    |     Premium Support

Work with image

I tried to load file by using map suite engine 2.0 and it worked .But when i use Map Suite Edition 3.0 it didn't work and give me this error


"Out of memory."  at mapEngine.OpenAllLayers(); line ,and those are the codes:


 


Working code using Map Suite Engine 2.0:


//*****************************************************


private void Form1_Load(object sender, EventArgs e)


...


...


 


ImageLayer imageLayer = new ImageLayer(@"C:\1\san_81.jpg");


 mMapEngine.ImageLayers.Add(imageLayer);


 DrawMap();


 


private void DrawMap()


        {


            Bitmap bitMap = new Bitmap(pictureBox1.Width, pictureBox1.Height);


            Graphics g = Graphics.FromImage(bitMap);


 


            mMapEngine.GetMap(g, mCurrentExtent, bitMap.Width, bitMap.Height, MapLengthUnits.DecimalDegrees, 0);


 


            pictureBox1.Image = bitMap;


            g.Dispose();


        }


//*****************************************************


 


 


not working code using Map Suite Desktop 3.0


 


//-------------------------------------------------------------------------------


 private void Form1_Load(object sender, EventArgs e)


{


...


...


 


 GdiPlusRasterLayer worldImageLayer = new GdiPlusRasterLayer(@"C:\1\san_81.jpg");


             worldImageLayer.UpperThreshold = double.MaxValue;


             worldImageLayer.LowerThreshold = 0;


 


             mapEngine.StaticLayers.Add("WorldImageLayer", worldImageLayer); 


        


 DrawImage();   


 


        }


 


 private void DrawImage()


        {


            


                mapEngine.OpenAllLayers();


                mapEngine.DrawStaticLayers(bitmap, GeographyUnit.DecimalDegree);


                mapEngine.CloseAllLayers();


 


                map.Image = bitmap;


           }


//----------------------------------------------------------------------------------


 


I want to know why it  works by using 2.0 and how to make it to work by using 3.0 because i want to be map suite 3.0 expert and buy it.


Also when i worked with 3.0 all information and codes work as i wanted except load image air(jpg).


 



Wasim, 
  
 Your 3.0 code works fine in my machine.  Just wonder what’s the size of your jpg file, is it very huge? Also please make sure you have the world file “*.jgw” there with your jpg.  In fact if it’s convenient can you send the file to me so we can have a detailed investigation here?  
  
 Ben 


Hi,


I have some problem with displaying a jpg file in 3.0 too. I have my .jgw file in the same folder as the image.


private void xPlayerControl_Load(object sender, EventArgs e)

        {


            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;

            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);



            GdiPlusRasterLayer worldImageLayer = new GdiPlusRasterLayer(@"c:\GISData\proj\V44.jpg");

            worldImageLayer.UpperThreshold = double.MaxValue;

            worldImageLayer.LowerThreshold = 0;



            LayerOverlay ImageOverlay = new LayerOverlay();

            ImageOverlay.Layers.Add("WorldImageLayer", worldImageLayer);



            winformsMap1.Overlays.Add(ImageOverlay);



            worldImageLayer.Open();

            RectangleShape startExtent = worldImageLayer.GetBoundingBox();

            worldImageLayer.Close();

            winformsMap1.CurrentExtent = startExtent;




            winformsMap1.Refresh();


}


 


This error is triggerd from the last row "winformsMap1.Refresh":



"InvalidOperationException


This method will return too many cells that might cause performance problem. Please use GetIntersectingGrid method instead."



What am I doing wrong?




regards H. Ärlehag



Hi there, 
  
 I’ve exactly the same issue with 3.0.313. 
 I’ve been able to work around by switching the thread mode to single thread. 
  
 Hope this helps. 
 Patrick.

Thanks for your reply. But Im sorry to say it does not help if I change the threading mode to singlethreading.


Any other ideas?


Henrik



Thanks for your sharing idea, Patrick! 
  
 Henrik, Welcome you to ThinkGeo Desktop Edition forum! 
  
 I think the problem is probably because you set wrong GeographicUnit for the data, Please try to set the GeographicUnit to Meter for the MapControl. 
  
 If you still cannot solve this problem, can you try to upload the jpg file to us? 
  
 Any more questions just let me know. 
  
 Thanks. 
  
 Yale 


Thank you Yale! 
  
 Now it works as a charm!

Henrik, Welcome! 
  
 Any other questions just let me know. 
  
 Thanks. 
  
 Yale