private void UpdateSize() { if (_source == null) { return; } int w = _source.Width, h = _source.Height; int palSize = grpPalette.Enabled ? (((int)numPaletteCount.Value * 2) + 0x40) : 0; lblDataSize.Text = String.Format("{0:n0}B", TextureConverter.Get((WiiPixelFormat)cboFormat.SelectedItem).GetMipOffset(ref w, ref h, (int)numLOD.Value + 1) + 0x40 + palSize); }
public void Replace(Bitmap bmp) { FileMap tMap; if (HasPlt) { tMap = TextureConverter.Get(_format).EncodeREFTTextureIndexed(bmp, LevelOfDetail, Palette.Entries.Length, PaletteFormat, QuantizationAlgorithm.MedianCut); } else { tMap = TextureConverter.Get(_format).EncodeREFTTexture(bmp, LevelOfDetail, WiiPaletteFormat.IA8); } ReplaceRaw(tMap); }
public void Replace(Bitmap bmp) { FileMap tMap, pMap; if (HasPalette) { PLT0Node pn = this.GetPaletteNode(); tMap = TextureConverter.Get(Format).EncodeTextureIndexed(bmp, LevelOfDetail, pn.Colors, pn.Format, QuantizationAlgorithm.MedianCut, out pMap); pn.ReplaceRaw(pMap); } else { tMap = TextureConverter.Get(Format).EncodeTexture(bmp, LevelOfDetail); } ReplaceRaw(tMap); }
public static void Replace(this TEX0Node tex0, Bitmap bmp, int paletteSize) { FileMap tMap, pMap; if (tex0.HasPalette) { PLT0Node pn = tex0.GetPaletteNode(); tMap = TextureConverter.Get(tex0.Format).EncodeTextureIndexed(bmp, tex0.LevelOfDetail, paletteSize, pn.Format, QuantizationAlgorithm.MedianCut, out pMap); pn.ReplaceRaw(pMap); } else { tMap = TextureConverter.Get(tex0.Format).EncodeTEX0Texture(bmp, tex0.LevelOfDetail); } tex0.ReplaceRaw(tMap); }
/// <summary> /// Replace the MenSelmapMark texture in toReplace with the image in newBitmap, flipping the channels if the image has solid black in all four corners. /// </summary> /// <param name="newBitmap">The new texture to use</param> /// <param name="toReplace">The TEX0 to insert the texture in</param> /// <param name="createNew">If true, the format of the existing texture will not be used as a fallback, even if useExistingAsFallback is true</param> private void ReplaceSelmapMark(Bitmap newBitmap, TEX0Node toReplace, bool createNew) { WiiPixelFormat format = selmapMarkFormat != null ? selmapMarkFormat.Value : useExistingAsFallback && !createNew ? toReplace.Format : BitmapUtilities.HasAlpha(newBitmap) ? WiiPixelFormat.IA4 : WiiPixelFormat.I4; Console.WriteLine(format); Bitmap toEncode = BitmapUtilities.HasSolidCorners(newBitmap) ? BitmapUtilities.AlphaSwap(newBitmap) : newBitmap; BrawlLib.IO.FileMap tMap = TextureConverter.Get(format).EncodeTEX0Texture(toEncode, 1); toReplace.ReplaceRaw(tMap); }
public TEX0v1(int width, int height, WiiPixelFormat format, int mipLevels) { _header._tag = Tag; _header._size = TextureConverter.Get(format).GetMipOffset(width, height, mipLevels + 1) + Size; _header._version = 1; _header._bresOffset = 0; _headerLen = Size; _stringOffset = 0; _hasPalette = ((format == WiiPixelFormat.CI4) || (format == WiiPixelFormat.CI8)) ? 1 : 0; _width = (short)width; _height = (short)height; _pixelFormat = (int)format; _levelOfDetail = mipLevels; _minLod = 0; _maxLod = mipLevels - 1.0f; _origPathOffset = 0; }
public TEX0(int width, int height, WiiPixelFormat format, int mipLevels) { _header._tag = Tag; _header._size = TextureConverter.Get(format).GetMipOffset(width, height, mipLevels + 1) + Size; _header._version = 1; _header._bresOffset = 0; _headerLen = Size; _stringOffset = 0; _hasPalette = ((format == WiiPixelFormat.CI4) || (format == WiiPixelFormat.CI8)) ? 1 : 0; _width = (short)width; _height = (short)height; _pixelFormat = (int)format; _levelOfDetail = mipLevels; _unknown = 0; _lodBias = mipLevels - 1.0f; fixed(uint *p = _padding) for (int i = 0; i < 4; i++) { p[i] = 0; } }
int DataSize() { return(TextureConverter.Get(Format).GetMipOffset(Width, Height, LevelOfDetail + 1)); }
private void btnOkay_Click(object sender, EventArgs e) { TextureConverter format = TextureConverter.Get((WiiPixelFormat)cboFormat.SelectedItem); if (format.IsIndexed) { _textureData = format.EncodeTextureIndexed(_indexed, (int)numLOD.Value, (WiiPaletteFormat)cboPaletteFormat.SelectedItem, out _paletteData); } else { if ((format.RawFormat == WiiPixelFormat.CMPR) && (_cmprBuffer != null)) { _textureData = ((CMPR)format).EncodeTextureCached(_source, (int)numLOD.Value, _cmprBuffer); } else { _textureData = format.EncodeTexture(_source, (int)numLOD.Value); } } if (_parent != null) { _original = _parent.CreateResource <TEX0Node>(Path.GetFileNameWithoutExtension(_imageSource)); if (_paletteData != null) { _originalPalette = _parent.CreateResource <PLT0Node>(_original.Name); _originalPalette.Name = _original.Name; _originalPalette.ReplaceRaw(_paletteData); } _original.ReplaceRaw(_textureData); } else if (_original != null) { if (_originalPalette != null) { if (_paletteData != null) { _originalPalette.ReplaceRaw(_paletteData); } else { _originalPalette.Remove(); _originalPalette.Dispose(); } } else if (_paletteData != null) { if ((_original.Parent == null) || (_original.Parent.Parent == null)) { _paletteData.Dispose(); _paletteData = null; } else { _parent = _original.Parent.Parent as BRESNode; _originalPalette = _parent.CreateResource <PLT0Node>(_original.Name); _originalPalette.Name = _original.Name; _originalPalette.ReplaceRaw(_paletteData); } } _original.ReplaceRaw(_textureData); } DialogResult = DialogResult.OK; Close(); }
public void Replace(Bitmap bmp) { ReplaceRaw(TextureConverter.Get(_format).EncodeREFTTexture(bmp, 1, WiiPaletteFormat.IA8, false)); }