Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
35cc98b
feat: Enhance image manipulation capabilities and add tests
google-labs-jules[bot] May 23, 2025
8343612
Create cmake-single-platform.yml
JacobBorden May 24, 2025
694a656
fix: Correct CMake configuration issues
google-labs-jules[bot] May 24, 2025
e49ba4d
Update CMakeLists.txt
JacobBorden May 24, 2025
d13b058
Update CMakeLists.txt
JacobBorden May 24, 2025
49100db
Merge branch 'development' into feature/image-processing-enhancements
JacobBorden May 24, 2025
23bfcad
Merge pull request #4 from JacobBorden/feature/image-processing-enhan…
JacobBorden May 24, 2025
f3397a9
Update CMakeLists.txt
JacobBorden May 24, 2025
9dac350
Update CMakeLists.txt
JacobBorden May 24, 2025
63f25b4
Update README.md
JacobBorden May 24, 2025
97eaa87
Update submodule commits and add .gitignore for build directory
JacobBorden May 25, 2025
3fec894
Add conditional compilation for ScreenShotWindow function on Windows
JacobBorden May 25, 2025
d3e5626
Add ScreenShotWindow function declaration for Windows
JacobBorden May 25, 2025
0fe626e
Fix bitmapInfo structure member names in CreateBitmapFromMatrix function
JacobBorden May 25, 2025
45acf30
Refactor image processing functions to use indexed access for pixel m…
JacobBorden May 25, 2025
37d1072
Fix bitmapInfo structure member names in ScreenShotWindow and CreateM…
JacobBorden May 25, 2025
fe2a815
Update CreateBitmapFromMatrix function signature to use const referen…
JacobBorden May 25, 2025
3d8d82c
Add definition for BI_RGB to ensure cross-platform compatibility
JacobBorden May 25, 2025
19f4f17
Add pixel manipulation functions for greyscale, brightness, saturatio…
JacobBorden May 25, 2025
aa07703
Add pixel contrast adjustment functions for individual color channels
JacobBorden May 25, 2025
038e45a
Integrate GoogleTest framework and update test structure for improved…
JacobBorden May 25, 2025
fdd67d3
Refactor CMakeLists.txt to improve library linking and organization
JacobBorden May 25, 2025
e2fb45a
Refactor bitmap tests to use Google Test macros
JacobBorden May 25, 2025
d7665a5
Enable colored output for BitmapUnitTests in CTest
JacobBorden May 25, 2025
114a679
Add CMake configuration for GoogleTest and test executable
JacobBorden May 25, 2025
844a387
Remove test executable and associated CTest configuration from CMakeL…
JacobBorden May 25, 2025
eb147c5
Remove main function from test_bitmap.cpp as tests are run through CTest
JacobBorden May 25, 2025
d88019f
Fix expected pixel color in InvertPixelColor test case
JacobBorden May 25, 2025
01faa32
Add Matrix Library Implementation and Documentation
JacobBorden May 26, 2025
baea9e4
Refactor CMakeLists.txt to remove unnecessary dependencies from test …
JacobBorden May 26, 2025
c436139
I've reorganized the repository, added tests, and updated the documen…
google-labs-jules[bot] May 26, 2025
9af3a64
Merge pull request #5 from JacobBorden/repo-reorg-and-tests
JacobBorden May 26, 2025
8a6de74
Here's a proposed change to your codebase:
google-labs-jules[bot] May 28, 2025
0527643
fix: Correct constructor syntax in Matrix.h for C++20
google-labs-jules[bot] May 28, 2025
318a733
fix: Correct Matrix method calls and Result<void> handling
google-labs-jules[bot] May 28, 2025
6629727
fix: Resolve multiple definition of main in tests
google-labs-jules[bot] May 28, 2025
0025dc2
Merge pull request #6 from JacobBorden/feat/bitmap-api-layer
JacobBorden May 28, 2025
82ca52a
Add fuzz testing for BMP header loading
google-labs-jules[bot] May 29, 2025
4b55b35
Fix: Correct method name in bitmap load test
google-labs-jules[bot] May 29, 2025
be40d65
Merge pull request #7 from JacobBorden/fuzz-load-bmp
JacobBorden May 29, 2025
d4854ee
Update fuzzing.yml
JacobBorden May 29, 2025
0bf6ae4
feat: Expand fuzz testing suite and enhance diagnostics
google-labs-jules[bot] May 29, 2025
571853e
Update fuzz_bitmap_file.cpp
JacobBorden May 29, 2025
6afb33f
Merge pull request #8 from JacobBorden/feature/expand-fuzz-testing
JacobBorden May 29, 2025
d422225
feat: Add validation for pixel data size in save function
JacobBorden May 29, 2025
31e588d
feat: Add overflow check for bitmap data size in load function and up…
JacobBorden May 29, 2025
8ac4273
feat: Improve overflow check in load function and refine operator* in…
JacobBorden May 29, 2025
b57773e
feat: Add additional check for bitmap data size in Save function
JacobBorden May 29, 2025
536bfab
feat: Add overflow check for bitmap dimensions in validateHeaders fun…
JacobBorden May 29, 2025
a8c12a5
feat: Add validation for matrix dimensions and bitmap data size in Cr…
JacobBorden May 29, 2025
00ac884
feat: Add SIMD pixel swizzling with tests and fuzzers
google-labs-jules[bot] May 30, 2025
7145dbd
fix: Add missing declaration for BGR->BGRA helper
google-labs-jules[bot] May 30, 2025
7a13904
fix: Resolve linker errors for swizzle helpers
google-labs-jules[bot] May 30, 2025
e2d3a43
fix: Qualify swizzle helper calls in fuzz targets
google-labs-jules[bot] May 30, 2025
1b943a0
ci: Run new swizzle fuzz targets in GitHub Actions
google-labs-jules[bot] May 30, 2025
fe0ad63
Merge pull request #9 from JacobBorden/feat/simd-swizzle-tests
JacobBorden May 30, 2025
6557531
Refactor BmpTool into a dedicated API layer and expose manipulation f…
google-labs-jules[bot] May 31, 2025
5aa50e8
It looks like you're providing a commit message. Is this something yo…
google-labs-jules[bot] May 31, 2025
b8eb1ed
Merge pull request #10 from JacobBorden/bmptool-api-refactor
JacobBorden May 31, 2025
4048b33
Add GitHub Actions workflow for extended analysis
google-labs-jules[bot] May 31, 2025
94455b4
Merge pull request #11 from JacobBorden/add-analysis-pipeline
JacobBorden May 31, 2025
58428fd
Docs: Comprehensive project documentation update
google-labs-jules[bot] May 31, 2025
48eb80b
Merge pull request #12 from JacobBorden/docs-update-20231120
JacobBorden May 31, 2025
f46ae0d
feat: Add Doxygen generation to CI workflow
google-labs-jules[bot] May 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Analysis Pipeline

on:
push:
branches: [ "master", "development" ]
pull_request:
branches: [ "master", "development" ]

env:
BUILD_TYPE: Debug # Note: This default BUILD_TYPE will be overridden in specific jobs as needed

jobs:
asan-msan:
name: ASan/MSan
runs-on: ubuntu-latest
env: # Overriding BUILD_TYPE for this specific job
BUILD_TYPE: Debug
steps:
- uses: actions/checkout@v4

- name: Install Doxygen
run: sudo apt-get update && sudo apt-get install -y doxygen

- name: Generate Doxygen Documentation
run: doxygen Doxyfile

- name: Upload Doxygen Documentation
uses: actions/upload-artifact@v3
with:
name: doxygen-html-docs
path: docs/doxygen/html

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DENABLE_ASAN=ON -DENABLE_MSAN=ON

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Test
working-directory: ${{github.workspace}}/build
run: ctest -C ${{env.BUILD_TYPE}}

valgrind:
name: Valgrind
needs: asan-msan
runs-on: ubuntu-latest
env: # Overriding BUILD_TYPE for this specific job
BUILD_TYPE: Release
steps:
- uses: actions/checkout@v4

- name: Install Valgrind
run: sudo apt-get update && sudo apt-get install -y valgrind

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Test with Valgrind
working-directory: ${{github.workspace}}/build
run: ctest -T memcheck -C ${{env.BUILD_TYPE}}

codeql-analysis:
name: CodeQL Analysis
needs: asan-msan # Depends on the initial build and test phase
runs-on: ubuntu-latest
permissions:
security-events: write # Required to upload CodeQL analysis results
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: cpp # Specify 'cpp' for C++
# config-file: ./.github/codeql/codeql-config.yml # Optional: if you have a custom config

- name: Autobuild
uses: github/codeql-action/autobuild@v3
# If autobuild fails, you might need to specify custom build steps here.
# For CMake projects, it usually works well.

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
39 changes: 39 additions & 0 deletions .github/workflows/cmake-single-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
name: CMake on a single platform

on:
push:
branches: [ "master", "development" ]
pull_request:
branches: [ "master", "development" ]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}}

73 changes: 73 additions & 0 deletions .github/workflows/fuzzing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Fuzzing

on:
push:
branches: [ main, development ]
pull_request:
branches: [ main, development ]

jobs:
fuzz:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Clang
run: |
sudo apt-get update
sudo apt-get install -y clang llvm

- name: Configure CMake for Fuzzing
run: |
cmake -S . -B build_fuzz -DENABLE_FUZZING=ON -DCMAKE_BUILD_TYPE=Debug
env:
CC: clang
CXX: clang++

- name: Build all fuzz targets
run: cmake --build build_fuzz --config Debug # This will build all executables configured for the Debug build

- name: Create corpus directories
run: |
mkdir -p build_fuzz/corpus_fuzzing/fuzz_bitmap_corpus
mkdir -p build_fuzz/corpus_fuzzing/fuzz_bmp_tool_save_corpus
mkdir -p build_fuzz/corpus_fuzzing/fuzz_bitmap_file_corpus
mkdir -p build_fuzz/corpus_fuzzing/fuzz_image_operations_corpus
mkdir -p build_fuzz/corpus_fuzzing/fuzz_matrix_corpus
mkdir -p build_fuzz/corpus_fuzzing/fuzz_convert_bgr_to_bgra_corpus
mkdir -p build_fuzz/corpus_fuzzing/fuzz_swizzle_bgra_to_rgba_corpus
mkdir -p build_fuzz/corpus_fuzzing/fuzz_swizzle_rgba_to_bgra_corpus

- name: Run fuzz_bitmap
run: |
./build_fuzz/tests/fuzz_bitmap -max_total_time=60 -print_final_stats=1 -print_pcs=1 -error_exitcode=1 build_fuzz/corpus_fuzzing/fuzz_bitmap_corpus/

- name: Run fuzz_bmp_tool_save
run: |
./build_fuzz/tests/fuzz_bmp_tool_save -max_total_time=60 -print_final_stats=1 -print_pcs=1 -error_exitcode=1 build_fuzz/corpus_fuzzing/fuzz_bmp_tool_save_corpus/

- name: Run fuzz_bitmap_file
run: |
./build_fuzz/tests/fuzz_bitmap_file -max_total_time=60 -print_final_stats=1 -print_pcs=1 -error_exitcode=1 build_fuzz/corpus_fuzzing/fuzz_bitmap_file_corpus/

- name: Run fuzz_image_operations
run: |
./build_fuzz/tests/fuzz_image_operations -max_total_time=60 -print_final_stats=1 -print_pcs=1 -error_exitcode=1 build_fuzz/corpus_fuzzing/fuzz_image_operations_corpus/

- name: Run fuzz_matrix
run: |
./build_fuzz/tests/fuzz_matrix -max_total_time=60 -print_final_stats=1 -print_pcs=1 -error_exitcode=1 build_fuzz/corpus_fuzzing/fuzz_matrix_corpus/

- name: Run fuzz_convert_bgr_to_bgra
run: |
./build_fuzz/tests/fuzz_convert_bgr_to_bgra -max_total_time=60 -print_final_stats=1 -print_pcs=1 -error_exitcode=1 build_fuzz/corpus_fuzzing/fuzz_convert_bgr_to_bgra_corpus/

- name: Run fuzz_swizzle_bgra_to_rgba
run: |
./build_fuzz/tests/fuzz_swizzle_bgra_to_rgba -max_total_time=60 -print_final_stats=1 -print_pcs=1 -error_exitcode=1 build_fuzz/corpus_fuzzing/fuzz_swizzle_bgra_to_rgba_corpus/

- name: Run fuzz_swizzle_rgba_to_bgra
run: |
./build_fuzz/tests/fuzz_swizzle_rgba_to_bgra -max_total_time=60 -print_final_stats=1 -print_pcs=1 -error_exitcode=1 build_fuzz/corpus_fuzzing/fuzz_swizzle_rgba_to_bgra_corpus/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
64 changes: 64 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Changelog

All notable changes to this project will be documented in this file.

## [0.3.0] - 2025-05-28

### Added
- **New Bitmap API Layer (`BmpTool`)**:
- Introduced a new public API header `include/bitmap.hpp`.
- Added `BmpTool::load(std::span<const uint8_t>)` function to load BMP data from a memory span into a `BmpTool::Bitmap` (RGBA format). This function bridges to the existing library's `::CreateMatrixFromBitmap` after parsing the input span.
- Added `BmpTool::save(const BmpTool::Bitmap&, std::span<uint8_t>)` function to save a `BmpTool::Bitmap` (RGBA) to a memory span. This function bridges to the existing library's `::CreateBitmapFromMatrix` and then serializes the resulting `::Bitmap::File` to the span.
- Defined `BmpTool::Bitmap` struct for RGBA pixel data and `BmpTool::Result` for error handling.
- Implemented the bridging logic in `src/format/bitmap.cpp`.
- Added Doxygen comments for the new public API.
- **API Roundtrip Test**:
- Added `tests/api_roundtrip.cpp` to verify that loading, saving, and re-loading a bitmap using the new API results in identical data.
- **Build System Updates**:
- Updated CMakeLists.txt files (root and tests) to include the new API implementation and test.
- Set C++ standard to C++20 globally in the root CMakeLists.txt.

### Changed
- The `bitmap` library now exposes the `BmpTool` API via `include/bitmap.hpp` for simplified bitmap operations.
- **Documentation**:
- Reviewed and significantly updated `README.md` for accuracy regarding features, API examples (old vs. new), build instructions, and added "Code Documentation" and "Contributing" sections.
- Reviewed and extensively updated `src/matrix/Documentation/Matrix.MD` to align with the current `src/matrix/matrix.h` implementation, including documenting move semantics, new functions, and correcting outdated information.

## [0.2.0] - 2024-07-27

### Changed
- Reorganized project structure: moved `bitmap.h` and `bitmap.cpp` to `src/bitmap/`. Updated include paths and CMakeLists.txt accordingly.
- Integrated `matrix` and `bitmapfile` modules directly into `src/` instead of a separate `dependencies` folder.

### Added
- Comprehensive unit tests for the `Bitmap::File` module (`tests/test_bitmap_file.cpp`), covering constructors, file operations (open, save, saveas), and validation logic.
- Comprehensive unit tests for the `Matrix` module (`tests/test_matrix.cpp`), covering constructors, arithmetic operations, manipulations (transpose, inverse, determinant), and merge/split functionality.

### Fixed
- Corrected include paths in various files to reflect the new project structure.
- Updated CMakeLists.txt files to correctly locate and build all source files and tests under the new structure.

## [0.1.0] - 2025-05-23

### Added
- New image manipulation functions:
- `InvertImageColors` / `InvertPixelColor`
- `ApplySepiaTone` / `ApplySepiaToPixel`
- `ApplyBoxBlur`
- Comprehensive unit testing framework (`tests/test_bitmap.cpp`) using basic assertions.
- Unit tests for most pixel-level functions (Greyscale, Invert, Sepia, Brightness, Contrast, Saturation, Luminance - including color-specific variants).
- Unit tests for image-level functions (`ApplyBoxBlur`, `ShrinkImage`, `RotateImageCounterClockwise`, and basic checks for others).
- This `README.md` and `CHANGELOG.md` file.

### Changed
- Refined contrast adjustment logic for secondary colors (`ChangePixelContrastMagenta`, `ChangePixelContrastYellow`, `ChangePixelContrastCyan`) to apply contrast to constituent primary channels directly.
- Improved inline code documentation (comments) in `src/bitmap.h` and `src/bitmap.cpp` for clarity and maintainability.
- Standardized clamping of pixel component values (0-255) in various functions.
- Corrected `std::min` usage in saturation and luminance functions.

### Fixed
- Corrected syntax errors in the original implementations of `ChangePixelContrastMagenta` and `ChangePixelContrastCyan`.
- Corrected variable name usage (`magenta` vs `cyan`) in `ChangePixelContrastCyan`.
- Improved GDI resource management in `ScreenShotWindow` by ensuring `DeleteDC`, `ReleaseDC`, and `DeleteObject` are called.
- Corrected a typo in `ChangePixelSaturationBlue` condition.
- Corrected a typo in the `ChangePixelBrightness` parameter name in `src/bitmap.h`.
71 changes: 49 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,60 @@
cmake_minimum_required(VERSION 3.0.0)
cmake_minimum_required(VERSION 3.10)
project(bitmap VERSION 1.0.0)

option(ENABLE_FUZZING "Enable fuzzing builds" OFF)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS OFF)

if(ENABLE_FUZZING)
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
find_program(CLANG_COMPILER NAMES clang++ clang)
if(CLANG_COMPILER)
set(CMAKE_CXX_COMPILER ${CLANG_COMPILER})
else()
message(WARNING "Clang compiler not found. Disabling fuzzing.")
set(ENABLE_FUZZING OFF)
endif()
endif()

if(ENABLE_FUZZING AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(STATUS "Fuzzing enabled. Using Clang compiler.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address,undefined,fuzzer-no-link")
# For linking fuzz targets, we'll use -fsanitize=fuzzer later
else()
message(STATUS "Fuzzing disabled or Clang not used.")
endif()
endif()

include(CTest)
enable_testing()
include(FetchContent)

FetchContent_Declare(
matrix
GIT_REPOSITORY https://github.com/JacobBorden/Matrix.git
SOURCE_DIR ../dependencies/matrix
)

FetchContent_Declare(
bitmapfile
GIT_REPOSITORY https://github.com/JacobBorden/BitmapFile.git
SOURCE_DIR ../dependencies/bitmapfile
# Add your main library with all sources
add_library(bitmap STATIC
src/bitmap/bitmap.cpp
src/bitmapfile/bitmap_file.cpp
src/format/bitmap.cpp
)

FetchContent_MakeAvailable(bitmapfile)
FetchContent_MakeAvailable(matrix)

link_libraries(matrix)
link_libraries(bitmapfile)
add_library(bitmap STATIC src/bitmap.cpp )
link_libraries(bitmap)
# Executable for main.cpp (if it's a demo or separate utility)
add_executable(testexe main.cpp)
target_link_libraries(testexe PRIVATE bitmap)

target_include_directories(bitmap PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/src/bitmapfile
${CMAKE_CURRENT_SOURCE_DIR}/src/matrix
)

# GoogleTest
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip
)
FetchContent_MakeAvailable(googletest)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set( CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include (Cpack)
# Add subdirectory for tests (enables gtest_discover_tests and test auto-discovery)
add_subdirectory(tests)
Loading
Loading