Pass blur strength from command line arguments
This commit is contained in:
parent
024dc2980e
commit
0f989add08
6
blur.c
6
blur.c
|
@ -24,9 +24,9 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "blur.h"
|
#include "blur.h"
|
||||||
|
|
||||||
/* Performs a simple 2D Gaussian blur of radius @radius on surface @surface. */
|
/* Performs a simple 2D Gaussian blur of standard devation @sigma surface @surface. */
|
||||||
void
|
void
|
||||||
blur_image_surface (cairo_surface_t *surface, int radius)
|
blur_image_surface (cairo_surface_t *surface, int sigma)
|
||||||
{
|
{
|
||||||
cairo_surface_t *tmp;
|
cairo_surface_t *tmp;
|
||||||
int width, height;
|
int width, height;
|
||||||
|
@ -73,8 +73,6 @@ blur_image_surface (cairo_surface_t *surface, int radius)
|
||||||
// [1]: http://www.peterkovesi.com/papers/FastGaussianSmoothing.pdf
|
// [1]: http://www.peterkovesi.com/papers/FastGaussianSmoothing.pdf
|
||||||
// [2]: https://en.wikipedia.org/wiki/Gaussian_blur#Mathematics
|
// [2]: https://en.wikipedia.org/wiki/Gaussian_blur#Mathematics
|
||||||
|
|
||||||
float sigma = 5;
|
|
||||||
|
|
||||||
int n = lrintf((sigma*sigma)/(SIGMA_AV*SIGMA_AV));
|
int n = lrintf((sigma*sigma)/(SIGMA_AV*SIGMA_AV));
|
||||||
if (n < 3) n = 3;
|
if (n < 3) n = 3;
|
||||||
|
|
||||||
|
|
3
blur.h
3
blur.h
|
@ -8,8 +8,7 @@
|
||||||
#define SIGMA_AV 2
|
#define SIGMA_AV 2
|
||||||
#define HALF_KERNEL KERNEL_SIZE / 2
|
#define HALF_KERNEL KERNEL_SIZE / 2
|
||||||
|
|
||||||
void blur_image_surface (cairo_surface_t *surface, int radius);
|
void blur_image_surface(cairo_surface_t *surface, int sigma);
|
||||||
|
|
||||||
void blur_impl_horizontal_pass_sse2(uint32_t *src, uint32_t *dst, int width, int height);
|
void blur_impl_horizontal_pass_sse2(uint32_t *src, uint32_t *dst, int width, int height);
|
||||||
void blur_impl_horizontal_pass_generic(uint32_t *src, uint32_t *dst, int width, int height);
|
void blur_impl_horizontal_pass_generic(uint32_t *src, uint32_t *dst, int width, int height);
|
||||||
|
|
||||||
|
|
12
i3lock.c
12
i3lock.c
|
@ -79,7 +79,7 @@ char date_format[32] = "%A, %m %Y\0";
|
||||||
/* opts for blurring */
|
/* opts for blurring */
|
||||||
bool blur = false;
|
bool blur = false;
|
||||||
bool step_blur = false;
|
bool step_blur = false;
|
||||||
int blur_radius = 5;
|
int blur_sigma = 5;
|
||||||
|
|
||||||
uint32_t last_resolution[2];
|
uint32_t last_resolution[2];
|
||||||
xcb_window_t win;
|
xcb_window_t win;
|
||||||
|
@ -866,7 +866,7 @@ int main(int argc, char *argv[]) {
|
||||||
{"timestr", required_argument, NULL, 0},
|
{"timestr", required_argument, NULL, 0},
|
||||||
{"datestr", required_argument, NULL, 0},
|
{"datestr", required_argument, NULL, 0},
|
||||||
|
|
||||||
{"blur", no_argument, NULL, 'B'},
|
{"blur", required_argument, NULL, 'B'},
|
||||||
|
|
||||||
{"ignore-empty-password", no_argument, NULL, 'e'},
|
{"ignore-empty-password", no_argument, NULL, 'e'},
|
||||||
{"inactivity-timeout", required_argument, NULL, 'I'},
|
{"inactivity-timeout", required_argument, NULL, 'I'},
|
||||||
|
@ -878,7 +878,7 @@ int main(int argc, char *argv[]) {
|
||||||
if ((username = pw->pw_name) == NULL)
|
if ((username = pw->pw_name) == NULL)
|
||||||
errx(EXIT_FAILURE, "pw->pw_name is NULL.\n");
|
errx(EXIT_FAILURE, "pw->pw_name is NULL.\n");
|
||||||
|
|
||||||
char *optstring = "hvnbdc:p:ui:teI:frsS:kB";
|
char *optstring = "hvnbdc:p:ui:teI:frsS:kB:";
|
||||||
while ((o = getopt_long(argc, argv, optstring, longopts, &optind)) != -1) {
|
while ((o = getopt_long(argc, argv, optstring, longopts, &optind)) != -1) {
|
||||||
switch (o) {
|
switch (o) {
|
||||||
case 'v':
|
case 'v':
|
||||||
|
@ -950,6 +950,7 @@ int main(int argc, char *argv[]) {
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
blur = true;
|
blur = true;
|
||||||
|
blur_sigma = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
if (strcmp(longopts[optind].name, "debug") == 0)
|
if (strcmp(longopts[optind].name, "debug") == 0)
|
||||||
|
@ -1084,7 +1085,8 @@ int main(int argc, char *argv[]) {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
errx(EXIT_FAILURE, "Syntax: i3lock-color [-v] [-n] [-b] [-d] [-c color] [-u] [-p win|default]"
|
errx(EXIT_FAILURE, "Syntax: i3lock-color [-v] [-n] [-b] [-d] [-c color] [-u] [-p win|default]"
|
||||||
" [-i image.png] [-t] [-e] [-I timeout] [-f] [-r|s] [-S screen_number] [-k] [--fuckton-of-color-args=rrggbbaa]");
|
" [-i image.png] [-t] [-e] [-I timeout] [-f] [-r|s] [-S screen_number] [-k]"
|
||||||
|
" [-B blur_strength] [--fuckton-of-color-args=rrggbbaa]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1207,7 +1209,7 @@ int main(int argc, char *argv[]) {
|
||||||
cairo_destroy(ctx);
|
cairo_destroy(ctx);
|
||||||
cairo_surface_destroy(xcb_img);
|
cairo_surface_destroy(xcb_img);
|
||||||
}
|
}
|
||||||
blur_image_surface(img, 10000);
|
blur_image_surface(img, blur_sigma);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pixmap on which the image is rendered to (if any) */
|
/* Pixmap on which the image is rendered to (if any) */
|
||||||
|
|
Loading…
Reference in New Issue