int bytesPerPixel = dibInfo.bitsPerPixel / 8;
    int rowSize = dibInfo.width * bytesPerPixel;
    int paddingSize = (4 - (rowSize % 4)) % 4;

    // Preallocate a buffer large enough for one row plus padding
    std::vector<char> buffer(rowSize + paddingSize, 0); // Initialize padding bytes to 0
    for (auto &x : buffer) {
      x = 0;
    }
    std::cout << std::endl;

    for (int x = dibInfo.height - 1; x >= 0; x--) {
        const std::vector<Pixel> &rowPixels = pixels[x];
        
        // Fill the buffer with pixel data
        for (int y = 0; y < dibInfo.width; y++) {
            const Pixel &pixel = rowPixels[y];
            
            if (dibInfo.bitsPerPixel == 8) {
                buffer[y] = static_cast<char>(pixel.blue);
            } else if (dibInfo.bitsPerPixel == 24) {
                buffer[y * 3] = static_cast<char>(pixel.blue);
                buffer[y * 3 + 1] = static_cast<char>(pixel.green);
                buffer[y * 3 + 2] = static_cast<char>(pixel.red);
            }
        }

        file.write(buffer.data(), buffer.size());
    }
Syscall param writev(vector[...]) points to uninitialised byte(s)
==9179==    at 0x4CBEA57: writev (writev.c:26)
==9179==    by 0x4941D91: std::__basic_file<char>::xsputn_2(char const*, long, char const*, long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30)
==9179==    by 0x4984D26: std::basic_filebuf<char, std::char_traits<char> >::xsputn(char const*, long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30)
==9179==    by 0x49AD375: std::ostream::write(char const*, long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30)
==9179==    by 0x10CEA5: Bitmap::write(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /content/LabWork1/main)
==9179==    by 0x11A7DC: rotateAndSave(Bitmap&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /content/LabWork1/main)
==9179==    by 0x1180D7: main (in /content/LabWork1/main)
==9179==  Address 0x54035e6 is 6 bytes inside a block of size 8,192 alloc'd
==9179==    at 0x484A2F3: operator new[](unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==9179==    by 0x4986023: std::basic_filebuf<char, std::char_traits<char> >::_M_allocate_internal_buffer() (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30)
==9179==    by 0x498A015: std::basic_filebuf<char, std::char_traits<char> >::open(char const*, std::_Ios_Openmode) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30)
==9179==    by 0x498AA7D: std::basic_ofstream<char, std::char_traits<char> >::basic_ofstream(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::_Ios_Openmode) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30)
==9179==    by 0x10C8D0: Bitmap::write(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /content/LabWork1/main)
==9179==    by 0x11A7DC: rotateAndSave(Bitmap&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /content/LabWork1/main)
==9179==    by 0x1180D7: main (in /content/LabWork1/main)
==9179==  Uninitialised value was created by a stack allocation
==9179==    at 0x10C88F: Bitmap::write(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /content/LabWork1/main)
==9179==