Advertisement
Harven

DirectDrawSurface.cpp patch

Feb 12th, 2019
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.53 KB | None | 0 0
  1. diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
  2. index a4281514e39..5f6b4feb64e 100644
  3. --- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
  4. +++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
  5. @@ -864,7 +864,7 @@ bool DDSHeader::isSrgb() const
  6.  
  7.  bool DDSHeader::hasAlpha() const
  8.  {
  9. -       return (pf.flags & DDPF_ALPHAPIXELS) != 0;
  10. +       return (pf.flags & DDPF_ALPHAPIXELS) != 0 || (pf.flags & DDPF_ALPHA) != 0;
  11.  }
  12.  
  13.  uint DDSHeader::d3d9Format() const
  14. @@ -949,7 +949,7 @@ bool DirectDrawSurface::isSupported() const
  15.                                 return false;
  16.                         }
  17.                 }
  18. -               else if ((header.pf.flags & DDPF_RGB) || (header.pf.flags & DDPF_LUMINANCE))
  19. +               else if ((header.pf.flags & DDPF_RGB) || (header.pf.flags & DDPF_LUMINANCE) || (header.pf.flags & DDPF_ALPHA))
  20.                 {
  21.                         // All RGB and luminance formats are supported now.
  22.                 }
  23. @@ -986,7 +986,7 @@ bool DirectDrawSurface::hasAlpha() const
  24.         }
  25.         else
  26.         {
  27. -               if (header.pf.flags & DDPF_RGB)
  28. +               if ((header.pf.flags & DDPF_RGB) || (header.pf.flags & DDPF_ALPHA))
  29.                 {
  30.                         return header.pf.amask != 0;
  31.                 }
  32. @@ -1124,7 +1124,7 @@ void DirectDrawSurface::mipmap(Image *img, uint face, uint mipmap)
  33.         }
  34.         else
  35.         {
  36. -               if (header.pf.flags & DDPF_RGB)
  37. +               if ((header.pf.flags & DDPF_RGB) || (header.pf.flags & DDPF_ALPHA))
  38.                 {
  39.                         readLinearImage(img);
  40.                 }
  41. @@ -1194,10 +1194,15 @@ void DirectDrawSurface::readLinearImage(Image *img)
  42.                         mem_read(stream, (unsigned char *)(&c), byteCount);
  43.  
  44.                         Color32 pixel(0, 0, 0, 0xFF);
  45. -                       pixel.r = PixelFormat::convert((c & header.pf.rmask) >> rshift, rsize, 8);
  46. -                       pixel.g = PixelFormat::convert((c & header.pf.gmask) >> gshift, gsize, 8);
  47. -                       pixel.b = PixelFormat::convert((c & header.pf.bmask) >> bshift, bsize, 8);
  48. -                       pixel.a = PixelFormat::convert((c & header.pf.amask) >> ashift, asize, 8);
  49. +                       if ( header.pf.flags & DDPF_ALPHA )
  50. +                               pixel.r = pixel.g = pixel.b = PixelFormat::convert((c & header.pf.amask) >> ashift, asize, 8);
  51. +                       else
  52. +                       {
  53. +                               pixel.r = PixelFormat::convert((c & header.pf.rmask) >> rshift, rsize, 8);
  54. +                               pixel.g = PixelFormat::convert((c & header.pf.gmask) >> gshift, gsize, 8);
  55. +                               pixel.b = PixelFormat::convert((c & header.pf.bmask) >> bshift, bsize, 8);
  56. +                               pixel.a = PixelFormat::convert((c & header.pf.amask) >> ashift, asize, 8);
  57. +                       }
  58.  
  59.                         img->pixel(x, y) = pixel;
  60.                 }
  61. @@ -1391,7 +1396,7 @@ uint DirectDrawSurface::mipmapSize(uint mipmap) const
  62.                 h = (h + 3) / 4;
  63.                 return blockSize() * w * h;
  64.         }
  65. -       else if (header.pf.flags & DDPF_RGB || (header.pf.flags & DDPF_LUMINANCE))
  66. +       else if (header.pf.flags & DDPF_RGB || (header.pf.flags & DDPF_LUMINANCE) || (header.pf.flags & DDPF_ALPHA))
  67.         {
  68.                 uint pitch = computePitch(w, header.pf.bitcount, 8); // Asuming 8 bit alignment, which is the same D3DX expects.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement