I have a need to keep an in memory copy of the ThinkGeo WinformsMap, so that I can periodically create a Bitmap object for a portion of the map Overlay. The idea is to load in a combination of Raster and Feature layers and generate a bitmap that covers some of the resulting image. Also, if the desired bitmap area is half off of the extent covered by the Overlay, it should be transparent or a solid color.
In the process of figuring out how to do this, I've found a lack of detail in the documentation in the ExtentHelper class. It would really help a lot of you guys could shore that up a bit so it is very clear what each function argument actually represents. I also recommend you use a better code documentation tool than NDOC -- I use Doc-O-Matic, which generates PDFs, HTML, CHM, and Windows help files well.
Anyway, suppose we have a class that performs the above functionality, and there are the following member properties:
- int PixelWidth -- width in pixels of output bitmap
- int PixelHeight -- width in pixels of output bitmap
- RectangleShape rs -- desired 'box' that is put in the bitmap
- WinformsMap _Map -- the ThinkGeo map with Width >= PixelWidth & Height >= PixelHeight
public Rectangle UpdateBitmap(RectangleShape rs)
{
_B = new Bitmap(PixelWidth, PixelHeight);
if (true)
{
// This method is a hack that kind of works, the upper left corner matches rs
// but it is an inefficient method.
Rectangle r = new Rectangle(0, 0, PixelWidth, PixelHeight);
RectangleShape save_rs = _Map.CurrentExtent;
_Map.CurrentExtent = rs;
_Map.DrawToBitmap(_B, r);
_Map.CurrentExtent = save_rs;
}
else
{
// This is what I tried to do, but could not get it to work
Rectangle r = ExtentHelper.ToScreenCoordinate(Map.CurrentExtent, rs, PixelWidth, PixelHeight);
_Map.DrawToBitmap(_B, r);
// I also tried ExtentHelper.ZoomIntoCenter, but could not get it to work
}
}
Any help you can provide would be most appreciated. The goal of this effort is to provide a transition to add the ability to read FeatureLayer sources and integrate it into our current map control as a quick ugprade. Later, we hope to use your map control instead. So, this process to generate the bitmap needs to be as efficient as possible.
NOTE: I looked very closely at all of the How Do I? examples, and they do not quite cover this situation. Any help you can provide would be most appreciated. It will very much help me in my evaluation process.