private void imageReceivedCallback(TextureRequestState state, AssetTexture asset) { if (state == TextureRequestState.Timeout) { // need a re-request if a texture times out but doing it here borks libomv //m_user.Assets.RequestImage(asset.AssetID, ImageType.Normal, imageReceivedCallback); return; } if (state != TextureRequestState.Finished) { return; } if (OnTextureDownloaded != null) { VTexture texture = new VTexture(); texture.TextureId = asset.AssetID; ManagedImage managedImage; Image tempImage; try { if (OpenJPEG.DecodeToImage(asset.AssetData, out managedImage, out tempImage)) { Bitmap textureBitmap = new Bitmap(tempImage.Width, tempImage.Height, PixelFormat.Format32bppArgb); Graphics graphics = Graphics.FromImage(textureBitmap); graphics.DrawImage(tempImage, 0, 0); graphics.Flush(); graphics.Dispose(); texture.Image = textureBitmap; OnTextureDownloaded(texture); } } catch (Exception e) { m_log.Error(":( :( :( :( got exception decoding image ): ): ): ):\nException: " + e.ToString()); } } }
private void imageReceivedCallback(TextureRequestState state, AssetTexture asset) { if (state == TextureRequestState.Timeout) { // need a re-request if a texture times out but doing it here borks libomv //m_user.Assets.RequestImage(asset.AssetID, ImageType.Normal, imageReceivedCallback); return; } if (state != TextureRequestState.Finished) return; if (OnTextureDownloaded != null) { VTexture texture = new VTexture(); texture.TextureId = asset.AssetID; ManagedImage managedImage; Image tempImage; try { if (OpenJPEG.DecodeToImage(asset.AssetData, out managedImage, out tempImage)) { Bitmap textureBitmap = new Bitmap(tempImage.Width, tempImage.Height, PixelFormat.Format32bppArgb); Graphics graphics = Graphics.FromImage(textureBitmap); graphics.DrawImage(tempImage, 0, 0); graphics.Flush(); graphics.Dispose(); texture.Image = textureBitmap; OnTextureDownloaded(texture); } } catch (Exception e) { m_log.Error(":( :( :( :( got exception decoding image ): ): ): ):\nException: " + e.ToString()); } } }