ThinkGeo.com    |     Documentation    |     Premium Support

Convert WorldData structure to RectangleShape

Desktop edition 2.0 used a WorldData structure to pass to the constructor of the ImageLayer. Desktop edition 3.0 uses a RectangleShape. I have data stored in the old WorldData format (e.g. CenterX, CenterY, ColumnRotation, RowRotationf, SizeX, SizeY). How do I convert this to a RectangleShape?



Hi Gregory,


You just need to make some little change to the Stream_Loading event like this:


private void ImageRasterLayer_StreamLoading(object sender, StreamLoadingEventArgs e)
{
    if (e.AlternateStreamName.Contains("BMP"))
    {
        // This is the bitmap stream.
        MemoryStream memoryStream = new MemoryStream();
        _rasterImage.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Bmp);
        e.AlternateStream = memoryStream;
    }
    else if (e.AlternateStreamName.Contains("BPW"))
    {
        // This is your world file string.
        string worldFile = "";
        MemoryStream memoryStream = new MemoryStream();
        StreamWriter writer = new StreamWriter(memoryStream);
        writer.Write(worldFile);
        e.AlternateStream = memoryStream;
    }



 
Hope this can help you.
 
Any more questions please let me know.
Thanks,
sun