-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Format C files according to google style
- Loading branch information
1 parent
1af0700
commit acd555e
Showing
19 changed files
with
206 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
all: deps build test | ||
|
||
deps: | ||
deps: FORCE | ||
CGO_CFLAGS_ALLOW=-Xpreprocessor go get ./... | ||
|
||
build: | ||
build: FORCE | ||
CGO_CFLAGS_ALLOW=-Xpreprocessor go build ./vips | ||
|
||
test: | ||
test: FORCE | ||
CGO_CFLAGS_ALLOW=-Xpreprocessor go test -v ./... | ||
|
||
FORCE: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
#include "arithmetic.h" | ||
|
||
int add(VipsImage *left, VipsImage *right, VipsImage **out) { | ||
return vips_add(left, right, out, NULL); | ||
return vips_add(left, right, out, NULL); | ||
} | ||
|
||
int multiply(VipsImage *left, VipsImage *right, VipsImage **out) { | ||
return vips_multiply(left, right, out, NULL); | ||
return vips_multiply(left, right, out, NULL); | ||
} | ||
|
||
int divide(VipsImage *left, VipsImage *right, VipsImage **out) { | ||
return vips_divide(left, right, out, NULL); | ||
return vips_divide(left, right, out, NULL); | ||
} | ||
|
||
int linear(VipsImage *in, VipsImage **out, double *a, double *b, int n) { | ||
return vips_linear(in, out, a, b, n, NULL); | ||
return vips_linear(in, out, a, b, n, NULL); | ||
} | ||
|
||
int linear1(VipsImage *in, VipsImage **out, double a, double b) { | ||
return vips_linear1(in, out, a, b, NULL); | ||
return vips_linear1(in, out, a, b, NULL); | ||
} | ||
|
||
int invert_image(VipsImage *in, VipsImage **out) { | ||
return vips_invert(in, out, NULL); | ||
return vips_invert(in, out, NULL); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,46 @@ | ||
#include "color.h" | ||
|
||
#include <unistd.h> | ||
|
||
int is_colorspace_supported(VipsImage *in) | ||
{ | ||
return vips_colourspace_issupported(in) ? 1 : 0; | ||
int is_colorspace_supported(VipsImage *in) { | ||
return vips_colourspace_issupported(in) ? 1 : 0; | ||
} | ||
|
||
int to_colorspace(VipsImage *in, VipsImage **out, VipsInterpretation space) | ||
{ | ||
return vips_colourspace(in, out, space, NULL); | ||
int to_colorspace(VipsImage *in, VipsImage **out, VipsInterpretation space) { | ||
return vips_colourspace(in, out, space, NULL); | ||
} | ||
|
||
// https://libvips.github.io/libvips/API/8.6/libvips-colour.html#vips-icc-transform | ||
int optimize_icc_profile(VipsImage *in, VipsImage **out, int isCmyk, char *srgb_profile_path, char *gray_profile_path) | ||
{ | ||
// todo: check current embedded profile, and skip if already set | ||
|
||
int channels = vips_image_get_bands(in); | ||
int result; | ||
|
||
if (vips_icc_present() == 0) | ||
{ | ||
return 1; | ||
} | ||
|
||
if (channels > 2) | ||
{ | ||
if (isCmyk == 1) | ||
{ | ||
result = vips_icc_transform(in, out, srgb_profile_path, "input_profile", "cmyk", "intent", VIPS_INTENT_PERCEPTUAL, NULL); | ||
} | ||
else | ||
{ | ||
result = vips_icc_transform(in, out, srgb_profile_path, "embedded", TRUE, "intent", VIPS_INTENT_PERCEPTUAL, NULL); | ||
// ignore embedded errors | ||
if (result != 0) | ||
{ | ||
result = 0; | ||
*out = in; | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
result = vips_icc_transform(in, out, gray_profile_path, "input_profile", gray_profile_path, "embedded", TRUE, "intent", VIPS_INTENT_PERCEPTUAL, NULL); | ||
} | ||
|
||
return result; | ||
int optimize_icc_profile(VipsImage *in, VipsImage **out, int isCmyk, | ||
char *srgb_profile_path, char *gray_profile_path) { | ||
// todo: check current embedded profile, and skip if already set | ||
|
||
int channels = vips_image_get_bands(in); | ||
int result; | ||
|
||
if (vips_icc_present() == 0) { | ||
return 1; | ||
} | ||
|
||
if (channels > 2) { | ||
if (isCmyk == 1) { | ||
result = | ||
vips_icc_transform(in, out, srgb_profile_path, "input_profile", | ||
"cmyk", "intent", VIPS_INTENT_PERCEPTUAL, NULL); | ||
} else { | ||
result = vips_icc_transform(in, out, srgb_profile_path, "embedded", TRUE, | ||
"intent", VIPS_INTENT_PERCEPTUAL, NULL); | ||
// ignore embedded errors | ||
if (result != 0) { | ||
result = 0; | ||
*out = in; | ||
} | ||
} | ||
} else { | ||
result = vips_icc_transform(in, out, gray_profile_path, "input_profile", | ||
gray_profile_path, "embedded", TRUE, "intent", | ||
VIPS_INTENT_PERCEPTUAL, NULL); | ||
} | ||
|
||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
#include "convolution.h" | ||
|
||
int gaussian_blur_image(VipsImage *in, VipsImage **out, double sigma) { | ||
return vips_gaussblur(in, out, sigma, NULL); | ||
return vips_gaussblur(in, out, sigma, NULL); | ||
} | ||
|
||
int sharpen_image(VipsImage *in, VipsImage **out, double sigma, double x1, double m2) { | ||
return vips_sharpen(in, out, "sigma", sigma, "x1", x1, "m2", m2, NULL); | ||
int sharpen_image(VipsImage *in, VipsImage **out, double sigma, double x1, | ||
double m2) { | ||
return vips_sharpen(in, out, "sigma", sigma, "x1", x1, "m2", m2, NULL); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,24 @@ | ||
// clang-format off | ||
// include order matters | ||
#include "lang.h" | ||
#include "create.h" | ||
// clang-format on | ||
|
||
// https://libvips.github.io/libvips/API/current/libvips-create.html#vips-xyz | ||
int xyz(VipsImage **out, int width, int height){ | ||
return vips_xyz(out, width, height, NULL); | ||
int xyz(VipsImage **out, int width, int height) { | ||
return vips_xyz(out, width, height, NULL); | ||
} | ||
|
||
// http://libvips.github.io/libvips/API/current/libvips-create.html#vips-black | ||
int black(VipsImage **out, int width, int height) { | ||
return vips_black(out, width, height, NULL); | ||
return vips_black(out, width, height, NULL); | ||
} | ||
|
||
// https://libvips.github.io/libvips/API/current/libvips-create.html#vips-identity | ||
int identity(VipsImage **out, int ushort) { | ||
if (ushort > 0){ | ||
return vips_identity(out, "ushort", TRUE, NULL); | ||
} else { | ||
return vips_identity(out, NULL); | ||
} | ||
if (ushort > 0) { | ||
return vips_identity(out, "ushort", TRUE, NULL); | ||
} else { | ||
return vips_identity(out, NULL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
#include "draw.h" | ||
|
||
#include "conversion.h" | ||
|
||
int draw_rect(VipsImage *in, double r, double g, double b, double a, int left, int top, int width, int height, int fill) { | ||
if (is_16bit(in->Type)) { | ||
r = 65535 * r / 255; | ||
g = 65535 * g / 255; | ||
b = 65535 * b / 255; | ||
a = 65535 * a / 255; | ||
} | ||
int draw_rect(VipsImage *in, double r, double g, double b, double a, int left, | ||
int top, int width, int height, int fill) { | ||
if (is_16bit(in->Type)) { | ||
r = 65535 * r / 255; | ||
g = 65535 * g / 255; | ||
b = 65535 * b / 255; | ||
a = 65535 * a / 255; | ||
} | ||
|
||
double background[3] = {r, g, b}; | ||
double backgroundRGBA[4] = {r, g, b, a}; | ||
double background[3] = {r, g, b}; | ||
double backgroundRGBA[4] = {r, g, b, a}; | ||
|
||
if (in->Bands <= 3) { | ||
return vips_draw_rect(in, background, 3, left, top, width, height, "fill", fill, NULL); | ||
} else { | ||
return vips_draw_rect(in, backgroundRGBA, 4, left, top, width, height, "fill", fill, NULL); | ||
} | ||
if (in->Bands <= 3) { | ||
return vips_draw_rect(in, background, 3, left, top, width, height, "fill", | ||
fill, NULL); | ||
} else { | ||
return vips_draw_rect(in, backgroundRGBA, 4, left, top, width, height, | ||
"fill", fill, NULL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,27 @@ | ||
#include "govips.h" | ||
|
||
static void govips_logging_handler( | ||
const gchar *log_domain, GLogLevelFlags log_level, | ||
const gchar *message, gpointer user_data) | ||
{ | ||
static void govips_logging_handler(const gchar *log_domain, | ||
GLogLevelFlags log_level, | ||
const gchar *message, gpointer user_data) { | ||
govipsLoggingHandler((char *)log_domain, (int)log_level, (char *)message); | ||
} | ||
|
||
static void null_logging_handler( | ||
const gchar *log_domain, GLogLevelFlags log_level, | ||
const gchar *message, gpointer user_data) | ||
{ | ||
} | ||
static void null_logging_handler(const gchar *log_domain, | ||
GLogLevelFlags log_level, const gchar *message, | ||
gpointer user_data) {} | ||
|
||
void vips_set_logging_handler(void) | ||
{ | ||
void vips_set_logging_handler(void) { | ||
g_log_set_default_handler(govips_logging_handler, NULL); | ||
} | ||
|
||
void vips_unset_logging_handler(void) | ||
{ | ||
void vips_unset_logging_handler(void) { | ||
g_log_set_default_handler(null_logging_handler, NULL); | ||
} | ||
|
||
/* This function skips the Govips logging handler and logs | ||
directly to stdout. To be used only for testing and debugging. | ||
Needed for CI because of a Go macOS bug which doesn't clean cgo callbacks on exit. */ | ||
void vips_default_logging_handler(void) | ||
{ | ||
Needed for CI because of a Go macOS bug which doesn't clean cgo callbacks on | ||
exit. */ | ||
void vips_default_logging_handler(void) { | ||
g_log_set_default_handler(g_log_default_handler, NULL); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.