|
| 1 | +using FFXIVLooseTextureCompiler.ImageProcessing; |
| 2 | +using SixLabors.ImageSharp; |
| 3 | +using SixLabors.ImageSharp.Formats.Png; |
| 4 | +using SixLabors.ImageSharp.PixelFormats; |
| 5 | + |
1 | 6 | namespace Penumbra.Import.Textures; |
2 | 7 |
|
3 | 8 | public partial class CombinedTexture : IDisposable |
@@ -138,8 +143,67 @@ public void Update() |
138 | 143 | break; |
139 | 144 | } |
140 | 145 | } |
| 146 | + public void ImageToEyeMaps(string path, string textureCompilerDLC) |
| 147 | + { |
| 148 | + if (!IsLoaded || _current == null) |
| 149 | + { |
| 150 | + return; |
| 151 | + } |
| 152 | + |
| 153 | + try |
| 154 | + { |
| 155 | + var image = Image.LoadPixelData<Rgba32>(_current.RgbaPixels, _current.TextureWrap!.Width, |
| 156 | + _current.TextureWrap!.Height); |
| 157 | + image.Save(path, new PngEncoder() { CompressionLevel = PngCompressionLevel.NoCompression }); |
| 158 | + ImageManipulation.ConvertToEyeMaps(path, textureCompilerDLC); |
| 159 | + } |
| 160 | + catch (Exception e) |
| 161 | + { |
141 | 162 |
|
142 | | - private void Clean() |
| 163 | + } |
| 164 | + } |
| 165 | + internal void EyeMultiToGrayscale(string path) |
| 166 | + { |
| 167 | + if (!IsLoaded || _current == null) |
| 168 | + { |
| 169 | + return; |
| 170 | + } |
| 171 | + |
| 172 | + try |
| 173 | + { |
| 174 | + var image = Image.LoadPixelData<Rgba32>(_current.RgbaPixels, _current.TextureWrap!.Width, |
| 175 | + _current.TextureWrap!.Height); |
| 176 | + image.Save(path, new PngEncoder() { CompressionLevel = PngCompressionLevel.NoCompression }); |
| 177 | + System.Drawing.Bitmap multi = TexLoader.ResolveBitmap(path); |
| 178 | + ImageManipulation.ExtractRed(multi).Save(ImageManipulation.AddSuffix(path, "_grayscale")); |
| 179 | + } |
| 180 | + catch (Exception e) |
| 181 | + { |
| 182 | + |
| 183 | + } |
| 184 | + } |
| 185 | + |
| 186 | + public void AtramentumLuminisDiffuseToGlowMap(string path) |
| 187 | + { |
| 188 | + if (!IsLoaded || _current == null) |
| 189 | + { |
| 190 | + return; |
| 191 | + } |
| 192 | + |
| 193 | + try |
| 194 | + { |
| 195 | + var image = Image.LoadPixelData<Rgba32>(_current.RgbaPixels, _current.TextureWrap!.Width, |
| 196 | + _current.TextureWrap!.Height); |
| 197 | + image.Save(path, new PngEncoder() { CompressionLevel = PngCompressionLevel.NoCompression }); |
| 198 | + System.Drawing.Bitmap diffuse = TexLoader.ResolveBitmap(path); |
| 199 | + AtramentumLuminisGlow.ExtractGlowMapFromDiffuse(diffuse).Save(path, System.Drawing.Imaging.ImageFormat.Png); |
| 200 | + } |
| 201 | + catch (Exception e) |
| 202 | + { |
| 203 | + |
| 204 | + } |
| 205 | + } |
| 206 | + private void Clean() |
143 | 207 | { |
144 | 208 | _centerStorage.Dispose(); |
145 | 209 | _current = null; |
|
0 commit comments