浏览代码

LibGfx/JPEGWriter: Add a named constant in add_scan_header()

No behavior change.
Nico Weber 1 年之前
父节点
当前提交
38526414b0
共有 1 个文件被更改,包括 6 次插入4 次删除
  1. 6 4
      Userland/Libraries/LibGfx/ImageFormats/JPEGWriter.cpp

+ 6 - 4
Userland/Libraries/LibGfx/ImageFormats/JPEGWriter.cpp

@@ -486,14 +486,16 @@ ErrorOr<void> add_scan_header(Stream& stream)
     // B.2.3 - Scan header syntax
     // B.2.3 - Scan header syntax
     TRY(stream.write_value<BigEndian<Marker>>(JPEG_SOS));
     TRY(stream.write_value<BigEndian<Marker>>(JPEG_SOS));
 
 
+    u16 const Ns = 3;
+
     // Ls - 6 + 2 × Ns
     // Ls - 6 + 2 × Ns
-    TRY(stream.write_value<BigEndian<u16>>(6 + 2 * 3));
+    TRY(stream.write_value<BigEndian<u16>>(6 + 2 * Ns));
 
 
     // Ns
     // Ns
-    TRY(stream.write_value<u8>(3));
+    TRY(stream.write_value<u8>(Ns));
 
 
-    // Encode 3 components
-    for (u8 i {}; i < 3; ++i) {
+    // Encode Ns components
+    for (u8 i {}; i < Ns; ++i) {
         // Csj
         // Csj
         TRY(stream.write_value<u8>(i + 1));
         TRY(stream.write_value<u8>(i + 1));