Skip to content

Commit 7151b24

Browse files
takaokoujiclaude
andcommitted
fix: use explicit PixelFormat::ARGB8888 in screenshot and fix read_pixels
- Update screenshot.rb to explicitly specify SDL2::PixelFormat::ARGB8888 instead of relying on format=0 default, ensuring consistent byte order across all platforms (including Wayland/Linux) - Update ruby-sdl2 submodule to include read_pixels fixes: - Accept SDL2::PixelFormat objects (not just Integer) - Remove incorrect ARGB8888 default override - Query renderer info for correct pitch when format=0 Addresses feedback from ohai/ruby-sdl2#29. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c63444a commit 7151b24

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

ruby/ruby-sdl2

ruby/smalruby3/lib/smalruby3/render/renderer/screenshot.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def maybe_save_screenshot
1919
return unless @screenshot_path && !File.symlink?(@screenshot_path)
2020

2121
require "smalruby3/smalruby3_imageutil"
22-
# read_pixels returns ARGB8888 (little-endian: BGRA bytes)
23-
argb_data = @sdl_renderer.read_pixels(nil, 0)
22+
# Explicitly request ARGB8888 for consistent byte order across platforms
23+
argb_data = @sdl_renderer.read_pixels(nil, SDL2::PixelFormat::ARGB8888)
2424
# Convert BGRA → RGBA for PNG encoding
2525
rgba_data = convert_bgra_to_rgba(argb_data)
2626
Smalruby3::ImageUtil.save_png(rgba_data, @width, @height, @screenshot_path)

0 commit comments

Comments
 (0)