Skip to content

Commit

Permalink
1.0: first version
Browse files Browse the repository at this point in the history
  • Loading branch information
zvezdochiot committed Dec 22, 2024
1 parent 9215cc3 commit adc35d0
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 7 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build Linux

on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Triggers the workflow on push or pull request events but only for the develop branch
# push:
# branches: [ develop ]
# pull_request:
# branches: [ develop ]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-20.04
name: Linux-x64
# - os: macos-13
# name: MacOS-x64
# - os: macos-14
# name: MacOS-arm64
steps:

- name: Linux Depends
if: matrix.name == 'Linux-x64'
run: |
sudo apt-get install libgimp2.0-dev
- name: Check out repo
uses: actions/checkout@v4

- name: Build Linux
if: (matrix.name == 'Linux-x64')
shell: bash
run: |
make
- name: Store build
if: (matrix.name == 'Linux-x64')
uses: actions/upload-artifact@v4
with:
name: gimp-reduce-colordepth_Linux_x64
path: plugin-gimp-reduce-colordepth
60 changes: 60 additions & 0 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Build Windows

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
# push:
# branches: [ main ]
# pull_request:
# branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
CI: true

jobs:
win:
strategy:
fail-fast: false
max-parallel: 2
matrix:
include: [
{msystem: MINGW32, toolchain: mingw-w64-i686, version: x32 },
{msystem: MINGW64, toolchain: mingw-w64-x86_64, version: x64 },
]
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
steps:
- name: Install msys2 build environment
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
update: false
install: base-devel git ${{ matrix.toolchain }}-toolchain ${{ matrix.toolchain }}-gimp


- run: git config --global core.autocrlf input
shell: bash

- uses: actions/checkout@v4

- name: Build plugin
shell: msys2 {0}
run: |
echo $(gimptool-2.0 -n --build src/main.c) | sh
mv main.exe plugin-gimp-reduce-colordepth-${{ matrix.version }}.exe
ls
- name: Get GIMP version
shell: msys2 {0}
run: echo "GIMPVER=$(pacman -Q ${{ matrix.toolchain }}-gimp | cut -d ' ' -f 2)" >> $GITHUB_ENV

- uses: actions/upload-artifact@v4
with:
name: plugin-gimp-reduce-colordepth_${{ env.GIMPVER }}_${{ matrix.version }}
path: |
./plugin-gimp-reduce-colordepth-${{ matrix.version }}.exe
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
plugin-gimp-reduce-colordepth
*.zip
*.7z
*.gz
*.exe
obj/
src/reference/
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ TARGET = plugin-gimp-reduce-colordepth
SRC_DIR = src
OBJ_DIR = obj

# -Wno-deprecated, -Wno-deprecated-declarations is just for gtk warnings for now (migration to GEGL)
CFLAGS = $(shell pkg-config --cflags gtk+-2.0) \
$(shell pkg-config --cflags gimp-2.0)
$(shell pkg-config --cflags gimp-2.0) \
-Wno-format-truncation \
-Wno-deprecated \
-Wno-deprecated-declarations
LFLAGS = $(shell pkg-config --libs glib-2.0) \
$(shell pkg-config --libs gtk+-2.0) \
$(shell pkg-config --libs gimp-2.0) \
Expand Down
12 changes: 11 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@ The functionality is similar to the built-in `Colors -> Dither` plugin except th
The plugin menu location is: `Colors -> Reduce Color Bit-Depth...`

## Compatibility
At least compatible with some versions of GIMP 2.10 on Linux
At least compatible with some versions of GIMP 2.10 on Linux and Windows.

## Download
Pre-built binaries can be downloaded from the [Releases section](https://github.com/bbbbbr/gimp-plugin-reduce-color-depth/releases).

## Install
Copy the plugin file to the relevant location below.

Plug-in folder locations:
- Linux: `~/.config/GIMP/2.10/plug-ins`
- Windows: `C:\Program Files\GIMP 2\lib\gimp\2.0\plug-ins`


Screenshot:
Expand Down
10 changes: 5 additions & 5 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,15 @@ static gboolean dialog(GimpDrawable * drawable) {
gtk_box_pack_start(GTK_BOX(main_vbox), table, FALSE, FALSE, 0);
gtk_widget_show(table);

adj_red = gtk_adjustment_new(settings.red_depth, 1, 8, 1, 1, 0);
adj_red = (GtkAdjustment *)gtk_adjustment_new(settings.red_depth, 1, 8, 1, 1, 0);
spin_red = gtk_spin_button_new(adj_red, 1.0, 0);
gimp_table_attach_aligned(GTK_TABLE(table), 0, 0, "Red Channel Depth:", 0.0, 0.5, spin_red, 1, TRUE);

adj_green = gtk_adjustment_new(settings.green_depth, 1, 8, 1, 1, 0);
adj_green = (GtkAdjustment *)gtk_adjustment_new(settings.green_depth, 1, 8, 1, 1, 0);
spin_green = gtk_spin_button_new(adj_green, 1.0, 0);
gimp_table_attach_aligned(GTK_TABLE(table), 0, 1, "Green Channel Depth:", 0.0, 0.5, spin_green, 1, TRUE);

adj_blue = gtk_adjustment_new(settings.blue_depth, 1, 8, 1, 1, 0);
adj_blue = (GtkAdjustment *)gtk_adjustment_new(settings.blue_depth, 1, 8, 1, 1, 0);
spin_blue = gtk_spin_button_new(adj_blue, 1.0, 0);
gimp_table_attach_aligned(GTK_TABLE(table), 0, 2, "Blue Channel Depth:", 0.0, 0.5, spin_blue, 1, TRUE);

Expand Down Expand Up @@ -308,7 +308,7 @@ static void ui_checkboxes_update(GtkToggleButton * widget, gpointer callback_dat
settings.clamp_lowest_bitval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_clamp_lowest_bitval));

if (settings.lock_channels)
ui_locked_channels_sync(adj_red, &settings.red_depth);
ui_locked_channels_sync((GtkWidget *)adj_red, &settings.red_depth);
}


Expand Down Expand Up @@ -357,7 +357,7 @@ static void process(GimpDrawable * drawable, GimpPreview * preview) {
//
// It doesn't seem to actually allocate the buffer (flushing with it fails, there are no
// reported GEGL buffer leaks on app shutdown), so I guess we won't bother to free it.
GeglBuffer * buffer = gimp_drawable_get_buffer(drawable);
GeglBuffer * buffer = gimp_drawable_get_buffer(drawable->drawable_id);


red_mask = ((1 << settings.red_depth) - 1) << (8 - settings.red_depth);
Expand Down

0 comments on commit adc35d0

Please sign in to comment.