Use FXARGB_[ARGB]() macros in more places.
Make code that effectively do the same thing more readable.
Change-Id: Id63ca4024e19e36d42c5d7e01668f6967ae64107
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/65615
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp
index 55090b3..fb109eb 100644
--- a/core/fpdfapi/page/cpdf_image.cpp
+++ b/core/fpdfapi/page/cpdf_image.cpp
@@ -239,9 +239,9 @@
uint8_t* ptr = pColorTable.get();
for (size_t i = 0; i < palette_size; i++) {
uint32_t argb = pBitmap->GetPaletteArgb(i);
- ptr[0] = (uint8_t)(argb >> 16);
- ptr[1] = (uint8_t)(argb >> 8);
- ptr[2] = (uint8_t)argb;
+ ptr[0] = FXARGB_R(argb);
+ ptr[1] = FXARGB_G(argb);
+ ptr[2] = FXARGB_B(argb);
ptr += 3;
}
auto pNewDict = m_pDocument->New<CPDF_Dictionary>();
diff --git a/core/fxcodec/progressivedecoder.cpp b/core/fxcodec/progressivedecoder.cpp
index dc26594..7582e16 100644
--- a/core/fxcodec/progressivedecoder.cpp
+++ b/core/fxcodec/progressivedecoder.cpp
@@ -1835,9 +1835,9 @@
int pixel_weight =
pPixelWeights->m_Weights[j - pPixelWeights->m_SrcStart];
unsigned long argb = m_pSrcPalette.get()[src_scan[j]];
- dest_r += pixel_weight * (uint8_t)(argb >> 16);
- dest_g += pixel_weight * (uint8_t)(argb >> 8);
- dest_b += pixel_weight * (uint8_t)argb;
+ dest_r += pixel_weight * FXARGB_R(argb);
+ dest_g += pixel_weight * FXARGB_G(argb);
+ dest_b += pixel_weight * FXARGB_B(argb);
}
*dest_scan++ =
(uint8_t)FXRGB2GRAY((dest_r >> 16), (dest_g >> 16), (dest_b >> 16));
@@ -1902,9 +1902,9 @@
int pixel_weight =
pPixelWeights->m_Weights[j - pPixelWeights->m_SrcStart];
unsigned long argb = m_pSrcPalette.get()[src_scan[j]];
- dest_r += pixel_weight * (uint8_t)(argb >> 16);
- dest_g += pixel_weight * (uint8_t)(argb >> 8);
- dest_b += pixel_weight * (uint8_t)argb;
+ dest_r += pixel_weight * FXARGB_R(argb);
+ dest_g += pixel_weight * FXARGB_G(argb);
+ dest_b += pixel_weight * FXARGB_B(argb);
}
*dest_scan++ = (uint8_t)((dest_b) >> 16);
*dest_scan++ = (uint8_t)((dest_g) >> 16);
@@ -1922,9 +1922,9 @@
int pixel_weight =
pPixelWeights->m_Weights[j - pPixelWeights->m_SrcStart];
unsigned long argb = m_pSrcPalette.get()[src_scan[j]];
- dest_r += pixel_weight * (uint8_t)(argb >> 16);
- dest_g += pixel_weight * (uint8_t)(argb >> 8);
- dest_b += pixel_weight * (uint8_t)argb;
+ dest_r += pixel_weight * FXARGB_R(argb);
+ dest_g += pixel_weight * FXARGB_G(argb);
+ dest_b += pixel_weight * FXARGB_B(argb);
}
*dest_scan++ = (uint8_t)((dest_b) >> 16);
*dest_scan++ = (uint8_t)((dest_g) >> 16);
@@ -1942,10 +1942,10 @@
int pixel_weight =
pPixelWeights->m_Weights[j - pPixelWeights->m_SrcStart];
unsigned long argb = m_pSrcPalette.get()[src_scan[j]];
- dest_a += pixel_weight * (uint8_t)(argb >> 24);
- dest_r += pixel_weight * (uint8_t)(argb >> 16);
- dest_g += pixel_weight * (uint8_t)(argb >> 8);
- dest_b += pixel_weight * (uint8_t)argb;
+ dest_a += pixel_weight * FXARGB_A(argb);
+ dest_r += pixel_weight * FXARGB_R(argb);
+ dest_g += pixel_weight * FXARGB_G(argb);
+ dest_b += pixel_weight * FXARGB_B(argb);
}
*dest_scan++ = (uint8_t)((dest_b) >> 16);
*dest_scan++ = (uint8_t)((dest_g) >> 16);