public static void ConvertTiffToDDS2(string tiffPath, bool overrideExisting = false) { string ddsPath = Path.ChangeExtension(tiffPath, ".dds"); if (overrideExisting || !StorageConfig.FileExists(ddsPath)) { var image = PixImage.Create(tiffPath, PixLoadOptions.UseSystemImage); // image.SaveAsImage(pngPath); var outFormat = image.PixFormat == PixFormat.ByteGray ? Rendering.AardvarkFormat.L8 : Rendering.AardvarkFormat.Dxt5; var target = SlimDx9TextureConvertible.CreateFile( new SlimDx9TextureConvertible.SlimDx9TextureParameters() { AardvarkFormat = outFormat, AardvarkUsage = AardvarkUsage.None, FileName = ddsPath, Pool = Pool.Scratch, MipMapLevels = 0 }); var con = image.Convertible(); con.ConvertInto(target); } }
public void DisposeSideEffects() { lock (asyncLock) { if (m_asyncTextures != null) { foreach (var tex in m_asyncTextures.Values) { var dxTex = SlimDx9TextureConvertible.OriginalTextureWithParameters(tex.Convertible); if (dxTex != null) { dxTex.Dispose(); } } m_asyncTextures = null; } } }
public static void ConvertTiffToDDS(string tiffPath, bool overrideExisting = false) { string ddsPath = Path.ChangeExtension(tiffPath, ".dds"); if (overrideExisting || !StorageConfig.FileExists(ddsPath)) { var bitmap = new Bitmap(tiffPath); // Konvertierung var target = SlimDx9TextureConvertible.CreateFile( new SlimDx9TextureConvertible.SlimDx9TextureParameters() { AardvarkFormat = Patch.GetTextureFormatFromPixelFormat(bitmap.PixelFormat), AardvarkUsage = AardvarkUsage.None, FileName = ddsPath, Pool = Pool.Scratch, MipMapLevels = 0 }); var bitmapConvertible = new Convertible("BitmapMemory", bitmap); bitmapConvertible.ConvertInto(target); } }
public ISg SetParameters(AbstractTraversal t) { if (!m_isInitialized) { var info = m_instance.PatchFileInfo; var bb = m_instance.PositionsType == PositionsType.V3dPositions ? info.LocalBoundingBox : info.LocalBoundingBox2d; var patch = new StreamingJob( () => { //TaskCombinators.Delay(100); //do importer logic here var patchVg = m_instance.LoadingStrategy.Load(m_instance.PatchFileInfo, m_instance.PatchFilePath, m_instance.PositionsType, true, true, true, m_instance.MaxTriangleSize); if (patchVg == null) { return(EmptyLeaf.Singleton); } var lodColor = Patch.GetLodColor(m_instance.Level, m_instance.MaxLevel); patchVg["LodColor"] = lodColor; for (int i = 0; i < patchVg.Textures.Count; i++) { var key = patchVg.Textures.Keys.ToList()[i]; var source = patchVg.Textures[key].Convertible; Convertible target = null; if (t.Renderer is SlimDx9Renderer) { target = SlimDx9TextureConvertible.Create( new SlimDx9TextureConvertible.SlimDx9TextureParameters() { //SlimDx9Format = SlimDX.Direct3D9.Format., // .Dxt5, Pool = SlimDX.Direct3D9.Pool.Default }); source.ConvertInto(target); } else { // nothing todo in slimdx10renderer (this just loads the texture on demand) // fix this if you are fed up with framerate hick ups target = source; } patchVg.Textures[key] = new Texture(target); } lock (asyncLock) { m_asyncTextures = patchVg.Textures; } return(patchVg.ToVertexGeometrySet()); }, bb, m_instance.MaxLevel - m_instance.Level, true); patch.DestructSideEffects = DisposeSideEffects; var placeHolder = Primitives.WireBox(bb, C4b.Red).ToVertexGeometrySet(); m_returnISg = new AsyncStreamingNode(patch, placeHolder) { DebugName = Path.GetFileName(m_instance.PatchFilePath), }; var local2Global = m_instance.PatchFileInfo.GetLocal2Global(m_instance.PositionsType); if (m_instance.InvertZ) { local2Global = M44d.Scale(1, 1, -1) * local2Global; } var global2Local = local2Global.Inverse; m_returnISg = Rsg.Apply(Rsg.Attribute.PushTrafo3d(new Trafo3d(local2Global, global2Local)), m_returnISg); m_isInitialized = true; } return(m_returnISg); }