コード例 #1
0
ファイル: VRAMController.cs プロジェクト: Sievaxx/LSDView
        public void LoadTIXIntoVRAM(string tixPath)
        {
            Logger.Log()(LogLevel.INFO, $"Loading TIX from {tixPath} into virtual VRAM");

            TIX tix;

            using (BinaryReader br = new BinaryReader(File.Open(tixPath, FileMode.Open)))
            {
                tix = new TIX(br);
            }

            Logger.Log()(LogLevel.INFO, $"Successfully loaded TIX");

            foreach (var chunk in tix.Chunks)
            {
                foreach (var tim in chunk.TIMs)
                {
                    var image = LibLSDUtil.GetImageDataFromTIM(tim);

                    int actualXPos = (tim.PixelData.XPosition - 320) * 2;
                    int actualYPos = 512 - tim.PixelData.YPosition - image.height;

                    VRAMTexture.SubImage(image.data, actualXPos, actualYPos, image.width, image.height);
                }
            }

            VRAMLoaded = true;
        }
コード例 #2
0
        /// <summary>
        /// Export a TIM file to a common image format.
        /// </summary>
        /// <param name="tim">The TIM file.</param>
        /// <param name="clutIndex">The index of the CLUT to export with.</param>
        /// <param name="filePath">The file path to export to.</param>
        /// <param name="format">The image format to export to.</param>
        public void ExportImage(TIM tim, int clutIndex, string filePath, ImageFormat format)
        {
            Log.Information($"Exporting image ({format}) to: {filePath}");

            var    image = LibLSDUtil.GetImageDataFromTIM(tim, clutIndex, flip: false);
            Bitmap bmp   = ImageUtil.ImageDataToBitmap(image.data, image.width, image.height);

            bmp.Save(filePath, format);
        }
コード例 #3
0
        public TIMDocument CreateDocument(TIM tim)
        {
            Mesh textureMesh = Mesh.CreateQuad(_shader);
            var  img         = LibLSDUtil.GetImageDataFromTIM(tim);

            textureMesh.Textures.Add(new Texture2D(img.width, img.height, img.data));

            return(new TIMDocument(tim, textureMesh));
        }
コード例 #4
0
        /// <summary>
        /// Export a TIM file to a common image format.
        /// </summary>
        /// <param name="tim">The TIM file.</param>
        /// <param name="filePath">The file path to export to.</param>
        /// <param name="format">The image format to export to.</param>
        public void ExportImage(TIM tim, string filePath, ImageFormat format)
        {
            Logger.Log()(LogLevel.INFO, $"Exporting image ({format}) to: {filePath}");

            var    image = LibLSDUtil.GetImageDataFromTIM(tim, flip: false);
            Bitmap bmp   = ImageUtil.ImageDataToBitmap(image.data, image.width, image.height);

            bmp.Save(filePath, format);
        }
コード例 #5
0
        public TIMDocument CreateDocument(TIM tim)
        {
            // 1 if not using CLUT, otherwise number of CLUTs
            int numMeshes = tim.ColorLookup?.NumberOfCLUTs ?? 1;

            Mesh[] timMeshes = new Mesh[numMeshes];

            for (int i = 0; i < numMeshes; i++)
            {
                var        img         = LibLSDUtil.GetImageDataFromTIM(tim, clutIndex: i);
                Mesh       textureMesh = Mesh.CreateQuad(_shader);
                ITexture2D tex         = new Texture2D(img.width, img.height, img.data);
                textureMesh.Textures.Add(tex);
                timMeshes[i] = textureMesh;
            }

            return(new TIMDocument(tim, timMeshes));
        }