protected virtual void GetMapImage(RegionInfo info) { try { string regionimage = "regionImage" + info.RegionID.ToString(); regionimage = regionimage.Replace("-", ""); WebClient c = new WebClient(); string uri = "http://" + info.ExternalHostName + ":" + info.HttpPort + "/index.php?method=" + regionimage; //m_log.Debug("JPEG: " + uri); c.DownloadFile(uri, info.RegionID.ToString() + ".jpg"); Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg"); //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); byte[] imageData = OpenJPEG.EncodeFromImage(m, true); AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString()); info.RegionSettings.TerrainImageID = ass.FullID; ass.Type = (int)AssetType.Texture; ass.Temporary = false; ass.Data = imageData; m_assetcache.AddAsset(ass); } catch // LEGIT: Catching problems caused by OpenJPEG p/invoke { m_log.Warn("[HGrid]: Failed getting/storing map image, because it is probably already in the cache"); } }
/// <summary> /// Handle raw uploaded baked texture data. /// </summary> /// <param name="data"></param> /// <param name="path"></param> /// <param name="param"></param> /// <returns></returns> public string BakedTextureUploaded(byte[] data, string path, string param) { String result; bool decodeFailed = false; UUID newAssetID = UUID.Random(); if (data.Length <= 0) { m_log.ErrorFormat("[CAPS]: Invalid length {0} on UploadBakeRequestPut for {1}", data.Length, path); decodeFailed = true; } else if (m_layerDecoder != null) { decodeFailed = (m_layerDecoder.Decode(newAssetID, data) == false); } if (decodeFailed) { Hashtable badReply = new Hashtable(); badReply["state"] = "error"; badReply["new_asset"] = UUID.Zero; result = LLSDHelpers.SerializeLLSDReply(badReply); } else { AssetBase asset = new AssetBase(newAssetID, "Baked Texture", (sbyte)AssetType.Texture, m_Caps.AgentID.ToString()); asset.Data = data; //Persist baked textures as we will use them in the baked texture cache //asset.Temporary = true; asset.Local = true; m_assetCache.AddAsset(asset, AssetRequestInfo.GenericNetRequest()); LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); uploadComplete.new_asset = newAssetID.ToString(); uploadComplete.new_inventory_item = UUID.Zero; uploadComplete.state = "complete"; result = LLSDHelpers.SerializeLLSDReply(uploadComplete); // m_log.DebugFormat("[BAKED TEXTURE UPLOADER]: baked texture upload completed for {0}", newAssetID); } m_Caps.HttpListener.RemoveStreamHandler("POST", m_uploaderPath); return(result); }