• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2022 The PDFium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CORE_FXGE_CALCULATE_PITCH_H_
6 #define CORE_FXGE_CALCULATE_PITCH_H_
7 
8 #include <stdint.h>
9 
10 #include <optional>
11 
12 namespace fxge {
13 
14 // Returns the bytes between successive rows of an image where rows are aligned
15 // on a byte boundary and there is no additional padding beyond that, or nullopt
16 // if the result can not fit in a uint32_t.
17 std::optional<uint32_t> CalculatePitch8(uint32_t bits_per_component,
18                                         uint32_t components_per_pixel,
19                                         int width_in_pixels);
20 
21 // Returns the bytes between successive rows of an image where rows are aligned
22 // on a 32-bit word boundary and there is no additional padding beyond that, or
23 // nullopt if the result can not fit in a uint32_t.
24 std::optional<uint32_t> CalculatePitch32(int bits_per_pixel,
25                                          int width_in_pixels);
26 
27 // Same as above, but terminate if the result can not fit in a uint32_t.
28 uint32_t CalculatePitch8OrDie(uint32_t bits_per_component,
29                               uint32_t components_per_pixel,
30                               int width_in_pixels);
31 uint32_t CalculatePitch32OrDie(int bits_per_pixel, int width_in_pixels);
32 
33 }  // namespace fxge
34 
35 #endif  // CORE_FXGE_CALCULATE_PITCH_H_
36