@@ -234,7 +234,7 @@ Result<capture_result_t> capture_full_screen_spectacle()
234234
235235 result.w = w;
236236 result.h = h;
237- result.data .assign (rgba, rgba + static_cast < size_t > (w) * h * 4 );
237+ result.data .assign (rgba, rgba + size_t (w) * h * 4 );
238238 stbi_image_free (rgba);
239239
240240 return Ok (std::move (result));
@@ -267,7 +267,7 @@ Result<capture_result_t> capture_full_screen_wayland()
267267 return Err (" Screenshot too large to decode (buffer > INT_MAX)." );
268268
269269 int w = 0 , h = 0 , comp = 0 ;
270- uint8_t * rgba = stbi_load_from_memory (buf.data (), static_cast < int > (buf.size ()), &w, &h, &comp, STBI_rgb_alpha);
270+ uint8_t * rgba = stbi_load_from_memory (buf.data (), int (buf.size ()), &w, &h, &comp, STBI_rgb_alpha);
271271
272272 if (!rgba)
273273 {
@@ -277,7 +277,7 @@ Result<capture_result_t> capture_full_screen_wayland()
277277
278278 result.w = w;
279279 result.h = h;
280- result.data .assign (rgba, rgba + (static_cast < size_t > (w) * static_cast < size_t > (h) * 4 ));
280+ result.data .assign (rgba, rgba + (size_t (w) * size_t (h) * 4 ));
281281 stbi_image_free (rgba);
282282
283283 return Ok (std::move (result));
@@ -470,7 +470,7 @@ Result<capture_result_t> capture_full_screen_portal()
470470
471471 st.cap .w = w;
472472 st.cap .h = h;
473- st.cap .data .assign (rgba, rgba + (static_cast < size_t > (w) * h * 4 ));
473+ st.cap .data .assign (rgba, rgba + (size_t (w) * h * 4 ));
474474 stbi_image_free (rgba);
475475
476476 // The portal backend (on KDE mostly) writes a permanent file to ~/Pictures named "Screenshot_*.png".
@@ -496,12 +496,12 @@ Result<capture_result_t> capture_full_screen_portal()
496496 if (new_w > 0 && new_h > 0 )
497497 {
498498 const int src_stride = st.cap .w ;
499- std::vector<uint8_t > cropped (static_cast < size_t > (new_w) * new_h * 4 );
499+ std::vector<uint8_t > cropped (size_t (new_w) * new_h * 4 );
500500 for (int row = 0 ; row < new_h; ++row)
501501 {
502- const uint8_t * src = st.cap .data .data () + (static_cast < size_t > (y0 + row) * src_stride + x0) * 4 ;
503- uint8_t * dst = cropped.data () + static_cast < size_t > (row) * new_w * 4 ;
504- std::memcpy (dst, src, static_cast < size_t > (new_w) * 4 );
502+ const uint8_t * src = st.cap .data .data () + (size_t (y0 + row) * src_stride + x0) * 4 ;
503+ uint8_t * dst = cropped.data () + size_t (row) * new_w * 4 ;
504+ std::memcpy (dst, src, size_t (new_w) * 4 );
505505 }
506506 st.cap .data = std::move (cropped);
507507 st.cap .w = new_w;
@@ -561,8 +561,8 @@ static int cursor_display_index()
561561 {
562562 if (active[i] == hit)
563563 {
564- debug (" macOS capture: display index {} (CGDirectDisplayID {})" , i + 1 , static_cast < unsigned > (hit));
565- return static_cast < int > (i + 1 );
564+ debug (" macOS capture: display index {} (CGDirectDisplayID {})" , i + 1 , unsigned (hit));
565+ return int (i + 1 );
566566 }
567567 }
568568
@@ -604,7 +604,7 @@ Result<capture_result_t> capture_full_screen_macos()
604604
605605 result.w = w;
606606 result.h = h;
607- result.data .assign (rgba, rgba + static_cast < size_t > (w) * h * 4 );
607+ result.data .assign (rgba, rgba + size_t (w) * h * 4 );
608608 stbi_image_free (rgba);
609609
610610 return Ok (std::move (result));
@@ -646,7 +646,7 @@ Result<capture_result_t> capture_full_screen_windows_fallback()
646646
647647 result.w = width;
648648 result.h = height;
649- result.data .resize (static_cast < size_t > (width) * height * 4 );
649+ result.data .resize (size_t (width) * height * 4 );
650650
651651 // Get Device Contexts
652652 HDC hScreenDC = GetDC (nullptr ); // virtual-desktop DC
@@ -712,7 +712,7 @@ static bool hr_failed(HRESULT hr, const char* what)
712712{
713713 if (FAILED (hr))
714714 {
715- debug (" {} failed: 0x{:08X}" , what, static_cast < unsigned > (hr));
715+ debug (" {} failed: 0x{:08X}" , what, unsigned (hr));
716716 return true ;
717717 }
718718 return false ;
@@ -730,7 +730,7 @@ struct com_ptr
730730 }
731731
732732 T** operator &() { return &ptr; }
733- T* operator -> () const { return ptr; }
733+ T* operator -() const { return ptr; }
734734 operator T*() const { return ptr; }
735735 operator bool () const { return ptr != nullptr ; }
736736
@@ -906,7 +906,7 @@ Result<capture_result_t> capture_full_screen_windows()
906906 desc.Format != DXGI_FORMAT_R8G8B8A8_UNORM && desc.Format != DXGI_FORMAT_R8G8B8A8_UNORM_SRGB)
907907 {
908908 duplication->ReleaseFrame ();
909- debug (" Unsupported DXGI format: {}" , static_cast < unsigned > (desc.Format ));
909+ debug (" Unsupported DXGI format: {}" , unsigned (desc.Format ));
910910 return capture_full_screen_windows_fallback ();
911911 }
912912
@@ -937,20 +937,20 @@ Result<capture_result_t> capture_full_screen_windows()
937937 }
938938
939939 // Copy to RGBA buffer
940- const uint8_t * src = static_cast < const uint8_t *> (mapped.pData );
940+ const uint8_t * src = const uint8_t *(mapped.pData );
941941 const uint32_t width = desc.Width ;
942942 const uint32_t height = desc.Height ;
943943
944- result.w = static_cast < int > (width);
945- result.h = static_cast < int > (height);
946- result.data .resize (static_cast < size_t > (width) * height * 4 );
944+ result.w = int (width);
945+ result.h = int (height);
946+ result.data .resize (size_t (width) * height * 4 );
947947
948948 if (desc.Format == DXGI_FORMAT_B8G8R8A8_UNORM || desc.Format == DXGI_FORMAT_B8G8R8A8_UNORM_SRGB)
949949 {
950950 for (uint32_t y = 0 ; y < height; ++y)
951951 {
952- const uint8_t * row = src + static_cast < size_t > (y) * mapped.RowPitch ;
953- uint8_t * out = result.data .data () + static_cast < size_t > (y) * width * 4 ;
952+ const uint8_t * row = src + size_t (y) * mapped.RowPitch ;
953+ uint8_t * out = result.data .data () + size_t (y) * width * 4 ;
954954
955955 for (uint32_t x = 0 ; x < width; ++x)
956956 {
@@ -966,9 +966,9 @@ Result<capture_result_t> capture_full_screen_windows()
966966 // R8G8B8A8
967967 for (uint32_t y = 0 ; y < height; ++y)
968968 {
969- const uint8_t * row = src + static_cast < size_t > (y) * mapped.RowPitch ;
970- uint8_t * out = result.data .data () + static_cast < size_t > (y) * width * 4 ;
971- std::memcpy (out, row, static_cast < size_t > (width) * 4 );
969+ const uint8_t * row = src + size_t (y) * mapped.RowPitch ;
970+ uint8_t * out = result.data .data () + size_t (y) * width * 4 ;
971+ std::memcpy (out, row, size_t (width) * 4 );
972972 }
973973 }
974974
0 commit comments