Skip to content

fix: address review feedback for Renderer#read_pixels#10

Merged
takaokouji merged 1 commit intomasterfrom
smalruby/add-read-pixels
Apr 14, 2026
Merged

fix: address review feedback for Renderer#read_pixels#10
takaokouji merged 1 commit intomasterfrom
smalruby/add-read-pixels

Conversation

@takaokouji
Copy link
Copy Markdown

Summary

SDL2::Renderer#read_pixels の修正。ohai#29 でのレビューフィードバックに対応。

Changes Made

  • SDL2::PixelFormat オブジェクトを受け付けるように修正(uint32_for_format() を使用)
  • format=0 のとき ARGB8888 に上書きしていたのを削除(SDL2 の仕様通りレンダリングターゲットのフォーマットを使用)
  • format=0 のとき正しい pitch を計算するためにレンダラー情報をクエリ
  • RDoc を改善(@overload、使用例、注意事項を追加)

Test Coverage

  • smalruby3 の screenshot.rbSDL2::PixelFormat::ARGB8888 を明示指定して動作確認済み
  • macOS Metal レンダラーで正常にスクリーンショットが保存されることを確認

Related Issues

Fixes #9
Upstream PR: ohai#29

- Accept SDL2::PixelFormat in addition to Integer by using
  uint32_for_format() instead of NUM2UINT()
- Remove incorrect ARGB8888 default override; pass format=0 through
  to SDL_RenderReadPixels as-is (SDL2 uses the rendering target's
  format when 0 is specified)
- Query renderer info to determine correct pitch when format is 0
- Improve RDoc with @overload, usage examples, and caveats

Addresses feedback from ohai#29.
Fixes #9

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@takaokouji takaokouji merged commit b46980d into master Apr 14, 2026
@takaokouji takaokouji deleted the smalruby/add-read-pixels branch April 14, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: address review feedback for Renderer#read_pixels (ohai/ruby-sdl2#29)

1 participant