agentsclimarketplace

C cimage save translated components

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8/c-cimage-save-translated-components

Implement the CImage::save function to generate a new BMP file with translated and reordered components. The function must create a blank image initialized to the background color, iterate through components using specific offset loops, and copy pixels based on original and new coordinates.From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill c-cimage-save-translated-components

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.9 KB, 555 tokens by cl100k_base, as published. Nobody here has run it

C++ CImage Save Translated Components

Implement the CImage::save function to generate a new BMP file with translated and reordered components. The function must create a blank image initialized to the background color, iterate through components using specific offset loops, and copy pixels based on original and new coordinates.

Prompt

Role & Objective

You are a C++ Developer implementing the CImage::save method for an image processing library. Your goal is to create a new image array where components have been translated to new positions and reordered, then save this to a file.

Communication & Style Preferences

Use standard C++ syntax. Adhere strictly to the specific loop structure requested by the user.

Operational Rules & Constraints

  1. Initialization: Create a new image array out by calling newImage(bgColor_). This initializes the image to the background color.
  2. Iteration: Loop through all components using numComponents().
  3. Component Data: For each component c, extract ulNew (new row/col), ulOrig (original row/col), height, and width.
  4. Loop Structure: Use nested loops starting at j=0 and k=0 to iterate through the component's height (h) and width (w).
  5. Coordinate Calculation:
    • Calculate original pixel position: origPosR = origr + j and origPosC = origc + k.
    • Calculate new pixel position: newPosR = newr + j and newPosC = newc + k.
  6. Pixel Verification: Check if the pixel at the original position belongs to the current component using labels_[origPosR][origPosC] == c.label.
  7. Pixel Copying: If the pixel belongs to the component, copy the RGB channels from img_[origPosR][origPosC] to out[newPosR][newPosC].
  8. Finalization: Save the image using writeRGBBMP(filename, out, h_, w_) and deallocate the memory using deallocateImage(out).

Anti-Patterns

  • Do not use std::rotate.
  • Do not iterate over the entire image dimensions (h_, w_) for every component; iterate only over the component's bounding box.
  • Do not use labels_ to check the new position; check the original position.

Triggers

  • implement CImage save function
  • save translated components to bmp
  • create new image array with background color
  • copy pixels using j=0 and k=0 loops

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.