Skip to content

Instantly share code, notes, and snippets.

@mr-yoo
Created September 11, 2025 15:37
Show Gist options
  • Save mr-yoo/f6902bd4027007edbc5c4535a59c7a0c to your computer and use it in GitHub Desktop.
Save mr-yoo/f6902bd4027007edbc5c4535a59c7a0c to your computer and use it in GitHub Desktop.
vieworks copilot instruction generated by AI

Image Processing C Library

Architecture Overview

  • Core Library: main.cpp - PNG processing with 8x8 block-based algorithms
  • Test Directories: testA/, testB/ with specific comment conventions
  • Missing Dependencies: function.h referenced but not present, STB headers external

Key Data Flow

  1. Load PNG → uint8_t frame[3][128][128] (RGB channels)
  2. Process in 8x8 blocks via raster scan (top-left to bottom-right)
  3. Apply per-block algorithms (e.g., brightness +40 with overflow clipping)
  4. Save processed frame back to PNG

Critical Functions Pattern

// Standard return pattern: 1=success, 0=failure
int read_png(const char* src_path, uint8_t frame[3][128][128]);
int write_png(uint8_t frame[3][128][128], const char* dst_path);

// Block processing with boundary checking
void read_frame(uint8_t channel_frame[128][128], int start_y, int start_x, uint8_t block[8][8]);

Memory Management Rules

  • Use stbi_image_free() for STB-allocated data
  • Use standard free() for manual allocations
  • Always NULL-check malloc results and implement safe cleanup (see free_png())

Build Requirements

  • No build system present - compile directly with C compiler
  • Requires STB single-header libraries: stb_image.h, stb_image_write.h
  • Standard C libraries only, no external linking
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment