gimp/libgimp/gimpbrush.h

53 lines
1.8 KiB
C
Raw Normal View History

libgimp, pdb: replacing gimp_brush_get_pixels() by gimp_brush_get_buffer()… … and gimp_brush_get_mask(). gimp_brush_get_pixels() was a bit crappy, returning raw data with only dimensions and bpp to go with (no color model/space, no bit depth…). So the assumption is that we work with 8-bit per channel data, possibly with alpha depending of number of channels as deduced from bpp, and very likely in sRGB color space. It might be globally ok with many of the brush formats (and historical brushes) but won't fare well as we improve brush capabilities. - gimp_brush_get_pixels() is in fact made private. - The 2 new functions are using this old PDB call _gimp_brush_get_pixels() to construct buffers. This has some limitations, in particular that it returns only 8-bit per channel sRGB data, but at least the signature won't change when we will improve things in the future (so if some day, we pass fancy brushes in high-bit depth, the method will stay the same). - This new implementation also allows scaling down the brush (keeping aspect ratio) which is useful when you need to fit a brush preview into a drawing widget. - Current implementation stores the buffers at native size in the libgimp's GimpBrush object, hence save re-querying the core every time you need an update. This can be improved as current implementation also means that you don't get updates if the brush changed. This should handle most common use cases for now, though. - Also with this change, I move GimpBrush class implementation into its own dedicated file.
2023-08-18 22:39:11 +08:00
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpbrush.h
* Copyright (C) 2023 Jehan
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#if !defined (__GIMP_H_INSIDE__) && !defined (GIMP_COMPILATION)
#error "Only <libgimp/gimp.h> can be included directly."
#endif
#ifndef __GIMP_BRUSH_H__
#define __GIMP_BRUSH_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
#include <libgimp/gimpresource.h>
#define GIMP_TYPE_BRUSH (gimp_brush_get_type ())
G_DECLARE_FINAL_TYPE (GimpBrush, gimp_brush, GIMP, BRUSH, GimpResource)
GeglBuffer * gimp_brush_get_buffer (GimpBrush *brush,
gint max_width,
gint max_height,
const Babl *format) G_GNUC_WARN_UNUSED_RESULT;
GeglBuffer * gimp_brush_get_mask (GimpBrush *brush,
gint max_width,
gint max_height,
const Babl *format) G_GNUC_WARN_UNUSED_RESULT;
G_END_DECLS
#endif /* __GIMP_BRUSH_H__ */