Explorar o código

Merge pull request #14 from V-Sekai/write-png

Always write png instead of jpg.
K. S. Ernest (iFire) Lee %!s(int64=3) %!d(string=hai) anos
pai
achega
869ac2e810
Modificáronse 2 ficheiros con 13 adicións e 22 borrados
  1. 3 3
      .github/workflows/build.yaml
  2. 10 19
      src/gltf/TextureBuilder.cpp

+ 3 - 3
.github/workflows/build.yaml

@@ -69,7 +69,7 @@ jobs:
 
       - name: Conan install
         run: |
-          conan install . --build=missing -i build -s build_type=Release -s compiler="Visual Studio"
+          conan install . -i build -s build_type=Release -s compiler="Visual Studio" --build missing
         shell: cmd
 
       - name: Conan build
@@ -171,7 +171,7 @@ jobs:
 
       - name: Conan install
         run: |
-          conan install . -i build -s build_type=Release --build fmt -s compiler.libcxx=libstdc++11
+          conan install . -i build -s build_type=Release --build fmt -s compiler.libcxx=libstdc++11 --build missing
         shell: bash
 
       - name: Conan build
@@ -276,7 +276,7 @@ jobs:
 
       - name: Conan install
         run: |
-          env CMAKE_OSX_ARCHITECTURES=x86_64 conan install . -i build -s build_type=Release --build missing --settings arch=x86_64
+          env CMAKE_OSX_ARCHITECTURES=x86_64 conan install . -i build -s build_type=Release --settings arch=x86_64 --build missing
         shell: bash
 
       - name: Conan build

+ 10 - 19
src/gltf/TextureBuilder.cpp

@@ -118,24 +118,15 @@ std::shared_ptr<TextureData> TextureBuilder::combine(
     }
   }
 
-  // write a .png iff we need transparency in the destination texture
-  bool png = includeAlphaChannel;
-
   std::vector<char> imgBuffer;
-  int res;
-  if (png) {
-    res = stbi_write_png_to_func(
-        WriteToVectorContext,
-        &imgBuffer,
-        width,
-        height,
-        channels,
-        mergedPixels.data(),
-        width * channels);
-  } else {
-    res = stbi_write_jpg_to_func(
-        WriteToVectorContext, &imgBuffer, width, height, channels, mergedPixels.data(), 80);
-  }
+  int res = stbi_write_png_to_func(
+      WriteToVectorContext,
+      &imgBuffer,
+      width,
+      height,
+      channels,
+      mergedPixels.data(),
+      width * channels);
   if (!res) {
     fmt::printf("Warning: failed to generate merge texture '%s'.\n", mergedFilename);
     return nullptr;
@@ -145,9 +136,9 @@ std::shared_ptr<TextureData> TextureBuilder::combine(
   if (options.outputBinary && !options.separateTextures) {
     const auto bufferView =
         gltf.AddRawBufferView(*gltf.defaultBuffer, imgBuffer.data(), to_uint32(imgBuffer.size()));
-    image = new ImageData(mergedName, *bufferView, png ? "image/png" : "image/jpeg");
+    image = new ImageData(mergedName, *bufferView, "image/png");
   } else {
-    const std::string imageFilename = mergedFilename + (png ? ".png" : ".jpg");
+    const std::string imageFilename = mergedFilename + (".png");
     const std::string imagePath = outputFolder + imageFilename;
     FILE* fp = fopen(imagePath.c_str(), "wb");
     if (fp == nullptr) {