private BlpTexture LoadTexture(string filename) { MpqFile file; Stream fileStream = null; BlpTexture texture; try { file = wowFileSystem.FindFile(filename); fileStream = file.Open(); texture = new BlpTexture(fileStream, false); } catch { texture = null; } finally { if (fileStream != null) { fileStream.Close(); } } return(texture); }
private Bitmap LoadBlpTextureAsBitmap(string filename) { if (filename == null) { throw new ArgumentNullException("filename"); } var file = wowFileSystem.FindFile(filename); if (file == null) { throw new FileNotFoundException(); } using (var stream = file.Open()) using (var texture = new BlpTexture(stream, false)) { var bitmap = new Bitmap(texture.Width, texture.Height, PixelFormat.Format32bppArgb); try { var bitmapData = bitmap.LockBits(new Rectangle(0, 0, texture.Width, texture.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); texture.FirstMipmap.CopyToArgb(new SurfaceData(bitmapData.Width, bitmapData.Height, bitmapData.Scan0, bitmapData.Stride)); bitmap.UnlockBits(bitmapData); return(bitmap); } catch { bitmap.Dispose(); throw; } } }
internal BlpPalettedMipmap(BlpTexture BaseTexture, int Width, int Height, bool AutoSet = true) : base(BaseTexture) { this.Width = Width; this.Height = Height; if (AutoSet) { _indexList = new byte[Width * Height]; if (BaseTexture.Alpha != 8) { _alphaList = new byte[(Width * Height * BaseTexture.Alpha + 7) / 8]; } } }
protected override void OnFileChanged() { if (File == null) { Texture = null; return; } else { Stream stream; BlpTexture texture = null; // Avoid the stupid catch-throw with this mini hack stream = File.Open(); try { texture = new BlpTexture(stream, false); } finally { stream.Close(); Texture = texture; } } }
private void UpdateDisplayInfo(SpellRecord spellRecord) { SpellIconRecord?spellIconRecord; spellInformation.SpellId = spellRecord.Id; spellIconRecord = spellIconDatabase[spellRecord.BookSpellIcon]; spellIconPictureBox.Image = null; if (spellIconRecord.HasValue) { try { currentIconTexture = LoadTexture(spellIconRecord.Value.Path + ".blp"); //spellIconPictureBox.Image = currentIconTexture.FirstMipMap; } catch { } } else { currentIconTexture.Dispose(); currentIconTexture = null; spellIconPictureBox.Image = null; } spellIdLabel.Text = spellRecord.Id.ToString(); spellLevelLabel.Text = spellRecord.LevelBase.ToString(); manaCostLabel.Text = spellRecord.ManaCost.ToString(); if (spellRecord.Rank != null && spellRecord.Rank.Length > 0) { spellNameLabel.Text = spellRecord.Name + " (" + spellRecord.Rank + ")"; } else { spellNameLabel.Text = spellRecord.Name; } spellDescriptionLabel.Text = spellInformation.BookDescription; spellEffect1Label.Text = spellInformation.Effect1Text; spellEffect2Label.Text = spellInformation.Effect2Text; spellEffect3Label.Text = spellInformation.Effect3Text; }
internal BlpJpegMipmap(BlpTexture BaseTexture, byte[] data) : base(BaseTexture) { _data = data; }
internal BlpMipmap(BlpTexture BaseTexture) { this.BaseTexture = BaseTexture; }