mirror of https://github.com/GNOME/gimp.git
app: coding styls cleanup in core/gimpbrush-transform.[ch]
This commit is contained in:
parent
5562f840b6
commit
6e65d1a392
|
@ -21,35 +21,40 @@
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
|
||||||
#include "core-types.h"
|
|
||||||
|
|
||||||
#include "libgimpmath/gimpmath.h"
|
#include "libgimpmath/gimpmath.h"
|
||||||
|
|
||||||
#include "gimpbrush.h"
|
#include "core-types.h"
|
||||||
#include "gimpbrush-transform.h"
|
|
||||||
|
|
||||||
#include "base/temp-buf.h"
|
#include "base/temp-buf.h"
|
||||||
#include "base/pixel-region.h"
|
#include "base/pixel-region.h"
|
||||||
|
|
||||||
#include "paint-funcs/paint-funcs.h"
|
#include "paint-funcs/paint-funcs.h"
|
||||||
|
|
||||||
|
#include "gimpbrush.h"
|
||||||
|
#include "gimpbrush-transform.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define MAX_BLUR_KERNEL 15
|
||||||
|
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
|
|
||||||
static void gimp_brush_transform_bounding_box (TempBuf *brush,
|
static void gimp_brush_transform_bounding_box (TempBuf *brush,
|
||||||
const GimpMatrix3 *matrix,
|
const GimpMatrix3 *matrix,
|
||||||
gint *x,
|
gint *x,
|
||||||
gint *y,
|
gint *y,
|
||||||
gint *width,
|
gint *width,
|
||||||
gint *height);
|
gint *height);
|
||||||
|
|
||||||
static gdouble gimp_brush_transform_array_sum (gfloat *arr,
|
static gdouble gimp_brush_transform_array_sum (gfloat *arr,
|
||||||
gint len);
|
gint len);
|
||||||
static void gimp_brush_transform_fill_blur_kernel (gfloat *arr,
|
static void gimp_brush_transform_fill_blur_kernel (gfloat *arr,
|
||||||
gint len);
|
gint len);
|
||||||
static gint gimp_brush_transform_blur_kernel_size (gint height,
|
static gint gimp_brush_transform_blur_kernel_size (gint height,
|
||||||
gint width,
|
gint width,
|
||||||
gdouble hardness);
|
gdouble hardness);
|
||||||
#define MAX_BLUR_KERNEL 15
|
|
||||||
|
|
||||||
/* public functions */
|
/* public functions */
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -218,10 +223,10 @@ gimp_brush_real_transform_mask (GimpBrush *brush,
|
||||||
src_tl_to_bl_delta_y = bly - tly;
|
src_tl_to_bl_delta_y = bly - tly;
|
||||||
|
|
||||||
/* speed optimized, note conversion to int precision */
|
/* speed optimized, note conversion to int precision */
|
||||||
src_walk_ux_i = (gint) ((src_tl_to_tr_delta_x / dest_width)* int_multiple);
|
src_walk_ux_i = (gint) ((src_tl_to_tr_delta_x / dest_width) * int_multiple);
|
||||||
src_walk_uy_i = (gint) ((src_tl_to_tr_delta_y / dest_width)* int_multiple);
|
src_walk_uy_i = (gint) ((src_tl_to_tr_delta_y / dest_width) * int_multiple);
|
||||||
src_walk_vx_i = (gint) ((src_tl_to_bl_delta_x / dest_height)* int_multiple);
|
src_walk_vx_i = (gint) ((src_tl_to_bl_delta_x / dest_height) * int_multiple);
|
||||||
src_walk_vy_i = (gint) ((src_tl_to_bl_delta_y / dest_height)* int_multiple);
|
src_walk_vy_i = (gint) ((src_tl_to_bl_delta_y / dest_height) * int_multiple);
|
||||||
|
|
||||||
/* initialize current position in source space to the start position (tl)
|
/* initialize current position in source space to the start position (tl)
|
||||||
* speed optimized, note conversion to int precision
|
* speed optimized, note conversion to int precision
|
||||||
|
@ -326,9 +331,9 @@ gimp_brush_real_transform_mask (GimpBrush *brush,
|
||||||
TempBuf *blur_src;
|
TempBuf *blur_src;
|
||||||
PixelRegion srcPR;
|
PixelRegion srcPR;
|
||||||
PixelRegion destPR;
|
PixelRegion destPR;
|
||||||
gint kernel_size = gimp_brush_transform_blur_kernel_size ( result->height,
|
gint kernel_size = gimp_brush_transform_blur_kernel_size (result->height,
|
||||||
result->width,
|
result->width,
|
||||||
hardness);
|
hardness);
|
||||||
gint kernel_len = kernel_size * kernel_size;
|
gint kernel_len = kernel_size * kernel_size;
|
||||||
gfloat blur_kernel [kernel_len];
|
gfloat blur_kernel [kernel_len];
|
||||||
|
|
||||||
|
@ -351,7 +356,6 @@ gimp_brush_real_transform_mask (GimpBrush *brush,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Transforms the brush pixmap with bilinear interpolation.
|
* Transforms the brush pixmap with bilinear interpolation.
|
||||||
*
|
*
|
||||||
|
@ -640,8 +644,6 @@ gimp_brush_real_transform_pixmap (GimpBrush *brush,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_brush_transform_matrix (gdouble width,
|
gimp_brush_transform_matrix (gdouble width,
|
||||||
gdouble height,
|
gdouble height,
|
||||||
|
@ -671,9 +673,9 @@ gimp_brush_transform_matrix (gdouble width,
|
||||||
gimp_matrix3_translate (matrix, - center_x * scale_x, - center_y * scale_y);
|
gimp_matrix3_translate (matrix, - center_x * scale_x, - center_y * scale_y);
|
||||||
gimp_matrix3_rotate (matrix, -2 * G_PI * angle);
|
gimp_matrix3_rotate (matrix, -2 * G_PI * angle);
|
||||||
gimp_matrix3_translate (matrix, center_x * scale_x, center_y * scale_y);
|
gimp_matrix3_translate (matrix, center_x * scale_x, center_y * scale_y);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* private functions */
|
/* private functions */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -706,48 +708,54 @@ gimp_brush_transform_bounding_box (TempBuf *brush,
|
||||||
*y = floor (temp_y);
|
*y = floor (temp_y);
|
||||||
|
|
||||||
/* Transform size can not be less than 1 px */
|
/* Transform size can not be less than 1 px */
|
||||||
*width = MAX(1, *width);
|
*width = MAX (1, *width);
|
||||||
*height = MAX(1, *height);
|
*height = MAX (1, *height);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gdouble
|
static gdouble
|
||||||
gimp_brush_transform_array_sum (gfloat *arr, gint len)
|
gimp_brush_transform_array_sum (gfloat *arr,
|
||||||
|
gint len)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
gfloat total = 0;
|
gfloat total = 0;
|
||||||
|
gint i;
|
||||||
|
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
total += arr [i];
|
total += arr [i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_brush_transform_fill_blur_kernel (gfloat *arr, gint len)
|
gimp_brush_transform_fill_blur_kernel (gfloat *arr,
|
||||||
|
gint len)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
gint half_point = ((gint) len / 2) + 1;
|
gint half_point = ((gint) len / 2) + 1;
|
||||||
|
gint i;
|
||||||
|
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
if (i < half_point)
|
if (i < half_point)
|
||||||
arr [i] = half_point - i;
|
arr [i] = half_point - i;
|
||||||
else arr [i] = i - half_point;
|
else
|
||||||
|
arr [i] = i - half_point;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
gimp_brush_transform_blur_kernel_size (gint height,
|
gimp_brush_transform_blur_kernel_size (gint height,
|
||||||
gint width,
|
gint width,
|
||||||
gdouble hardness)
|
gdouble hardness)
|
||||||
{
|
{
|
||||||
|
gint kernel_size = (MIN (MAX_BLUR_KERNEL,
|
||||||
|
MIN (width, height)) *
|
||||||
|
((MIN (width, height) * (1.0 - hardness)) /
|
||||||
|
MIN (width, height)));
|
||||||
|
|
||||||
gint kernel_size = MIN (MAX_BLUR_KERNEL, MIN(width, height)) *
|
/* Kernel size must be odd */
|
||||||
((MIN (width, height) * (1.0 - hardness)) / MIN (width, height));
|
if (kernel_size % 2 == 0)
|
||||||
|
kernel_size++;
|
||||||
/*Kernel size must be odd*/
|
|
||||||
if ( kernel_size % 2 == 0) kernel_size++;
|
|
||||||
|
|
||||||
return kernel_size;
|
return kernel_size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* GIMP - The GNU Image Manipulation Program
|
/* GIMP - The GNU Image Manipulation Program
|
||||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
*
|
*
|
||||||
* gimpbrush-scale.h
|
* gimpbrush-transform.h
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -23,29 +23,29 @@
|
||||||
|
|
||||||
/* virtual functions of GimpBrush, don't call directly */
|
/* virtual functions of GimpBrush, don't call directly */
|
||||||
|
|
||||||
void gimp_brush_real_transform_size (GimpBrush *brush,
|
void gimp_brush_real_transform_size (GimpBrush *brush,
|
||||||
gdouble scale,
|
gdouble scale,
|
||||||
gdouble aspect_ratio,
|
gdouble aspect_ratio,
|
||||||
gdouble angle,
|
gdouble angle,
|
||||||
gint *scaled_width,
|
gint *scaled_width,
|
||||||
gint *scaled_height);
|
gint *scaled_height);
|
||||||
TempBuf * gimp_brush_real_transform_mask (GimpBrush *brush,
|
TempBuf * gimp_brush_real_transform_mask (GimpBrush *brush,
|
||||||
gdouble scale,
|
gdouble scale,
|
||||||
gdouble aspect_ratio,
|
gdouble aspect_ratio,
|
||||||
gdouble angle,
|
gdouble angle,
|
||||||
gdouble hardness);
|
gdouble hardness);
|
||||||
TempBuf * gimp_brush_real_transform_pixmap (GimpBrush *brush,
|
TempBuf * gimp_brush_real_transform_pixmap (GimpBrush *brush,
|
||||||
gdouble scale,
|
gdouble scale,
|
||||||
gdouble aspect_ratio,
|
gdouble aspect_ratio,
|
||||||
gdouble angle,
|
gdouble angle,
|
||||||
gdouble hardness);
|
gdouble hardness);
|
||||||
|
|
||||||
void gimp_brush_transform_matrix (gdouble width,
|
void gimp_brush_transform_matrix (gdouble width,
|
||||||
gdouble height,
|
gdouble height,
|
||||||
gdouble scale,
|
gdouble scale,
|
||||||
gdouble aspect_ratio,
|
gdouble aspect_ratio,
|
||||||
gdouble angle,
|
gdouble angle,
|
||||||
GimpMatrix3 *matrix);
|
GimpMatrix3 *matrix);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_BRUSH_SCALE_H__ */
|
#endif /* __GIMP_BRUSH_SCALE_H__ */
|
||||||
|
|
Loading…
Reference in New Issue