feat: add image-pixels-testcard example (flat RGBA pixel buffer + save() lifecycle witness)#60
Merged
Merged
Conversation
…e() lifecycle witness) The gallery had no coverage of bpy.types.Image, and bulk pixels.foreach_set was an explicit ROADMAP candidate. A procedural broadcast test card written with one foreach_set witnesses the contracts AI-generated image code gets wrong: the buffer is always flat RGBA (channels == 4 even with alpha=False), byte storage quantizes at exactly <= 0.5/255 and strictly > 0, scale() reallocates so stale-size bulk reads raise, and Image.save() silently flips source to FILE and drops the in-memory buffer -- later pixels reads come from whatever sits on disk, proven by overwriting the file with an imposter. save_render() is the non-destructive path. All contracts probed identical on 4.5.11 LTS and 5.1.2. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
examples/image-pixels-testcard— a procedural broadcast test card (seven neon bars, luminance ramp, PLUGE row with a bottom-left origin marker, the classic circle) written intobpy.data.images.new()with onepixels.foreach_set()call (512×288×4 = 589,824 floats), rendered on an emissive studio monitor. Fills thebpy.types.Imagegap in the gallery; bulkpixels.foreach_setwas an explicit ROADMAP candidate.API contract witnessed
Image.pixelsis a flat, row-major, bottom-left-origin float buffer that is always RGBA:channels == 4andlen(pixels) == w*h*4even withalpha=False; an RGB-strideforeach_setraisesTypeError.float_buffer=Trueround-trips at float32 precision.Image.scale()reallocates the buffer; a stale-sizeforeach_getraises instead of shearing rows.save()trap (discovered while authoring, identical on 4.5 LTS and 5.1):save()on a GENERATED image silently flipssourcetoFILEand drops the in-memory buffer (has_data→ False); every laterpixelsread re-loads from whatever sits atfilepath_raw.save_render()writes the same PNG non-destructively.What each check catches (falsified once, then restored)
W*H*3write → exit 3byte_err > 0scale()reallocationsave()source-flip + imposter readsave_render()→ exit 7Version divergence
None — every contract asserts identically on 4.5.11 LTS and 5.1.2 (probed both before authoring). Only the optional render path gates the EEVEE engine id.
Visual notes
Dark-studio monitor at three-quarter angle, emissive card (
Closestinterpolation so the jagged circle edge is the actual 512×288 buffer), teal underglow accent, warm rim. The white PLUGE square sits bottom-left because that is where pixel (0,0) lives — a top-down origin assumption would visibly flip it. Iterated four times (blank screen from missing UVs → washed-out bars → clipped circle/stray glow ends → final).Test plan
Proven by live run on this machine:
python scripts/build_gallery.pyregenerateddocs/gallery/(20 detail pages)By inspection / CI only:
xvfb-runsmoke steps (this PR's 4.5/5.1 jobs)--engine cyclesrender path (code-identical to sibling examples; not exercised locally)🤖 Generated with Claude Code