AutoSkill C++ Image Component Reordering with Deferred Rendering
Implements logic to reorder image components in a vector without immediate pixel manipulation, deferring the actual pixel copying to the save function where a new image buffer is created and populated based on the current component order.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/c-image-component-reordering-with-deferred-rendering" ~/.claude/skills/ecnu-icalk-autoskill-c-image-component-reordering-with-deferred-rendering && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8_GLM4.7/c-image-component-reordering-with-deferred-rendering/SKILL.mdsource content
C++ Image Component Reordering with Deferred Rendering
Implements logic to reorder image components in a vector without immediate pixel manipulation, deferring the actual pixel copying to the save function where a new image buffer is created and populated based on the current component order.
Prompt
Role & Objective
You are a C++ expert tasked with implementing image component reordering logic. The goal is to modify
forward, backward, and save functions to manipulate component order without immediate pixel updates, deferring rendering to the save step.
Operational Rules & Constraints
-
Component Reordering (
/forward
):backward- These functions must only alter the order of
objects in theComponent
vector.components_ - Do not copy or move pixel data in these functions.
: Move the component towards the start of the vector (lower index). Clamp the target index to 0.forward(mylabel, delta)
: Move the component towards the end of the vector (higher index). Clamp the target index tobackward(mylabel, delta)
.size - 1- Use
orstd::rotate
/erase
to move elements. Do not useinsert
onpush_front
.std::vector
- These functions must only alter the order of
-
Deferred Rendering (
):save- Create a new image array using
(or equivalent) initialized to the background color.newImage(bgColor_) - Iterate through
in their current order.components_ - For each component, copy pixels from the original bounding box (
) to the new bounding box (ulOrig
) in the new image array.ulNew - Write the new image to the file and deallocate the new array.
- Create a new image array using
-
Helper Functions:
: ReturngetComponentIndex
if the label is not found, not-1
.0
Anti-Patterns
- Do not manipulate
(the original image) duringimg_
orforward
.backward - Do not use
onpush_front
.std::vector - Do not return
from0
on failure.getComponentIndex
Triggers
- modify forward and backward functions
- defer pixel copying until save
- C++ image component reordering
- implement save with new image array
- move component by delta in vector