diff options
Diffstat (limited to 'core/fxge/dib/cfx_dibitmap.cpp')
-rw-r--r-- | core/fxge/dib/cfx_dibitmap.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp index ae9bf244f0..9fa9776df0 100644 --- a/core/fxge/dib/cfx_dibitmap.cpp +++ b/core/fxge/dib/cfx_dibitmap.cpp @@ -19,7 +19,7 @@ namespace { -const int8_t g_ChannelOffset[] = {0, 2, 1, 0, 0, 1, 2, 3, 3}; +const int8_t kChannelOffset[] = {0, 2, 1, 0, 0, 1, 2, 3, 3}; } // namespace @@ -274,7 +274,7 @@ bool CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, if (!pSrcClone) return false; } - srcOffset = g_ChannelOffset[srcChannel]; + srcOffset = kChannelOffset[srcChannel]; } int destOffset = 0; if (destChannel == FXDIB_Alpha) { @@ -304,7 +304,7 @@ bool CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, return false; } } - destOffset = g_ChannelOffset[destChannel]; + destOffset = kChannelOffset[destChannel]; } if (srcChannel == FXDIB_Alpha && pSrcClone->m_pAlphaMask) { RetainPtr<CFX_DIBSource> pAlphaMask = pSrcClone->m_pAlphaMask; @@ -383,7 +383,7 @@ bool CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, int value) { return false; } } - destOffset = g_ChannelOffset[destChannel]; + destOffset = kChannelOffset[destChannel]; } int Bpp = GetBPP() / 8; if (Bpp == 1) { @@ -819,14 +819,15 @@ bool CFX_DIBitmap::CalculatePitchAndSize(int height, if (width <= 0 || height <= 0) return false; - if (!(format & 0xff)) + int bpp = GetBppFromFormat(format); + if (!bpp) return false; - if ((INT_MAX - 31) / width < (format & 0xff)) + if ((INT_MAX - 31) / width < bpp) return false; if (!*pitch) - *pitch = static_cast<uint32_t>((width * (format & 0xff) + 31) / 32 * 4); + *pitch = static_cast<uint32_t>((width * bpp + 31) / 32 * 4); if ((1 << 30) / *pitch < static_cast<uint32_t>(height)) return false; @@ -1190,7 +1191,7 @@ bool CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format) { } return true; } - int dest_bpp = dest_format & 0xff; + int dest_bpp = GetBppFromFormat(dest_format); int dest_pitch = (dest_bpp * m_Width + 31) / 32 * 4; std::unique_ptr<uint8_t, FxFreeDeleter> dest_buf( FX_TryAlloc(uint8_t, dest_pitch * m_Height + 4)); |