/// <summary> /// Gets current map preview as a bitmap. /// </summary> /// <returns>Map preview as a bitmap. Null if the preview could not be loaded.</returns> public Bitmap GetMapPreview() { if (previewBitmap != null) { return(previewBitmap); } string[] keys = GetKeys("PreviewPack"); if (keys == null || keys.Length == 0) { return(null); } int previewWidth = PreviewWidth; int previewHeight = PreviewHeight; if (previewWidth < 1 || previewHeight < 1) { return(null); } StringBuilder sb = new StringBuilder(); foreach (string key in keys) { sb.Append(GetKey("PreviewPack", key, string.Empty)); } byte[] dataDest = new byte[previewWidth * previewHeight * 3]; string errorMsg = MapPackHelper.ParseMapPackData(sb.ToString(), ref dataDest); if (errorMsg != null) { return(null); } previewBitmap = GraphicsUtils.CreateBitmapFromImageData(previewWidth, previewHeight, dataDest); return(previewBitmap); }