mirror of https://github.com/GNOME/gimp.git
app: turn the TempBuf's "bytes" into "format" and port everything to it
This commit is contained in:
parent
b4e3843b6a
commit
7441a1f6f7
|
@ -10,7 +10,8 @@ INCLUDES = \
|
|||
-I$(top_srcdir)/app \
|
||||
$(BABL_CFLAGS) \
|
||||
$(CAIRO_CFLAGS) \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(GEGL_CFLAGS) \
|
||||
$(GDK_PIXBUF_CFLAGS) \
|
||||
-I$(includedir)
|
||||
|
||||
noinst_LIBRARIES = libappbase.a
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <babl/babl.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "base-types.h"
|
||||
|
@ -95,8 +96,8 @@ pixel_region_init_temp_buf (PixelRegion *PR,
|
|||
PR->curtile = NULL;
|
||||
PR->offx = 0;
|
||||
PR->offy = 0;
|
||||
PR->bytes = temp_buf->bytes;
|
||||
PR->rowstride = temp_buf->width * temp_buf->bytes;
|
||||
PR->bytes = babl_format_get_bytes_per_pixel (temp_buf->format);
|
||||
PR->rowstride = temp_buf->width * PR->bytes;
|
||||
PR->x = x;
|
||||
PR->y = y;
|
||||
PR->w = w;
|
||||
|
|
|
@ -36,22 +36,24 @@
|
|||
TempBuf *
|
||||
temp_buf_new (gint width,
|
||||
gint height,
|
||||
gint bytes)
|
||||
const Babl *format)
|
||||
{
|
||||
TempBuf *temp;
|
||||
|
||||
g_return_val_if_fail (width > 0 && height > 0, NULL);
|
||||
g_return_val_if_fail (bytes > 0, NULL);
|
||||
g_return_val_if_fail (format != NULL, NULL);
|
||||
|
||||
temp = g_slice_new (TempBuf);
|
||||
|
||||
temp->bytes = bytes;
|
||||
temp->format = format;
|
||||
temp->width = width;
|
||||
temp->height = height;
|
||||
temp->x = 0;
|
||||
temp->y = 0;
|
||||
|
||||
temp->data = g_new (guchar, width * height * bytes);
|
||||
temp->data = g_new (guchar,
|
||||
width * height *
|
||||
babl_format_get_bytes_per_pixel (format));
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
@ -63,7 +65,7 @@ temp_buf_copy (TempBuf *src)
|
|||
|
||||
g_return_val_if_fail (src != NULL, NULL);
|
||||
|
||||
dest = temp_buf_new (src->width, src->height, src->bytes);
|
||||
dest = temp_buf_new (src->width, src->height, src->format);
|
||||
|
||||
if (! dest)
|
||||
return NULL;
|
||||
|
@ -85,6 +87,7 @@ temp_buf_scale (TempBuf *src,
|
|||
guchar *dest_data;
|
||||
gdouble x_ratio;
|
||||
gdouble y_ratio;
|
||||
gint bytes;
|
||||
gint loop1;
|
||||
gint loop2;
|
||||
|
||||
|
@ -93,7 +96,7 @@ temp_buf_scale (TempBuf *src,
|
|||
|
||||
dest = temp_buf_new (new_width,
|
||||
new_height,
|
||||
src->bytes);
|
||||
src->format);
|
||||
|
||||
src_data = temp_buf_get_data (src);
|
||||
dest_data = temp_buf_get_data (dest);
|
||||
|
@ -101,6 +104,8 @@ temp_buf_scale (TempBuf *src,
|
|||
x_ratio = (gdouble) src->width / (gdouble) new_width;
|
||||
y_ratio = (gdouble) src->height / (gdouble) new_height;
|
||||
|
||||
bytes = babl_format_get_bytes_per_pixel (src->format);
|
||||
|
||||
for (loop1 = 0 ; loop1 < new_height ; loop1++)
|
||||
{
|
||||
for (loop2 = 0 ; loop2 < new_width ; loop2++)
|
||||
|
@ -110,13 +115,13 @@ temp_buf_scale (TempBuf *src,
|
|||
gint i;
|
||||
|
||||
src_pixel = src_data +
|
||||
(gint) (loop2 * x_ratio) * src->bytes +
|
||||
(gint) (loop1 * y_ratio) * src->bytes * src->width;
|
||||
(gint) (loop2 * x_ratio) * bytes +
|
||||
(gint) (loop1 * y_ratio) * bytes * src->width;
|
||||
|
||||
dest_pixel = dest_data +
|
||||
(loop2 + loop1 * new_width) * src->bytes;
|
||||
(loop2 + loop1 * new_width) * bytes;
|
||||
|
||||
for (i = 0 ; i < src->bytes; i++)
|
||||
for (i = 0 ; i < bytes; i++)
|
||||
*dest_pixel++ = *src_pixel++;
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +143,7 @@ temp_buf_demultiply (TempBuf *buf)
|
|||
|
||||
g_return_if_fail (buf != NULL);
|
||||
|
||||
switch (buf->bytes)
|
||||
switch (babl_format_get_bytes_per_pixel (buf->format))
|
||||
{
|
||||
case 1:
|
||||
break;
|
||||
|
@ -196,13 +201,13 @@ temp_buf_get_data (const TempBuf *buf)
|
|||
gsize
|
||||
temp_buf_get_data_size (TempBuf *buf)
|
||||
{
|
||||
return buf->bytes * buf->width * buf->height;
|
||||
return babl_format_get_bytes_per_pixel (buf->format) * buf->width * buf->height;
|
||||
}
|
||||
|
||||
guchar *
|
||||
temp_buf_data_clear (TempBuf *buf)
|
||||
{
|
||||
memset (buf->data, 0, buf->height * buf->width * buf->bytes);
|
||||
memset (buf->data, 0, temp_buf_get_data_size (buf));
|
||||
|
||||
return buf->data;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
struct _TempBuf
|
||||
{
|
||||
gint bytes; /* number of bytes per pixel (1,2,3 or 4) */
|
||||
const Babl *format; /* pixel format */
|
||||
gint width;
|
||||
gint height;
|
||||
gint x, y; /* origin of data source */
|
||||
|
@ -34,7 +34,7 @@ struct _TempBuf
|
|||
|
||||
TempBuf * temp_buf_new (gint width,
|
||||
gint height,
|
||||
gint bytes);
|
||||
const Babl *fomat);
|
||||
TempBuf * temp_buf_copy (TempBuf *src);
|
||||
TempBuf * temp_buf_scale (TempBuf *buf,
|
||||
gint width,
|
||||
|
|
|
@ -17,12 +17,14 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gegl.h>
|
||||
|
||||
#include "base-types.h"
|
||||
#include "core/core-types.h" /* eek, but this file is cruft anyway */
|
||||
|
||||
#include "paint-funcs/subsample-region.h"
|
||||
|
||||
#include "gegl/gimp-gegl-utils.h"
|
||||
|
||||
#include "pixel-region.h"
|
||||
#include "temp-buf.h"
|
||||
#include "tile-manager.h"
|
||||
|
@ -97,7 +99,7 @@ tile_manager_create_preview (TileManager *tiles,
|
|||
gint subsample = 1;
|
||||
|
||||
preview = temp_buf_new (dest_width, dest_height,
|
||||
tile_manager_bpp (tiles));
|
||||
gimp_bpp_to_babl_format (tile_manager_bpp (tiles)));
|
||||
|
||||
pixel_region_init (&srcPR, tiles, src_x, src_y, src_width, src_height, FALSE);
|
||||
|
||||
|
|
|
@ -469,7 +469,7 @@ gimp_edit_fill_full (GimpImage *image,
|
|||
return TRUE; /* nothing to do, but the fill succeded */
|
||||
|
||||
if (pattern &&
|
||||
(pattern->mask->bytes == 2 || pattern->mask->bytes == 4) &&
|
||||
babl_format_has_alpha (pattern->mask->format) &&
|
||||
! gimp_drawable_has_alpha (drawable))
|
||||
{
|
||||
format = gimp_drawable_get_format_with_alpha (drawable);
|
||||
|
|
|
@ -48,9 +48,7 @@ gimp_brush_transform_boundary_exact (GimpBrush *brush,
|
|||
GimpBoundSeg *bound_segs;
|
||||
gint n_bound_segs;
|
||||
|
||||
buffer = gimp_temp_buf_create_buffer ((TempBuf *) mask,
|
||||
babl_format ("Y u8"),
|
||||
FALSE);
|
||||
buffer = gimp_temp_buf_create_buffer ((TempBuf *) mask, FALSE);
|
||||
|
||||
bound_segs = gimp_boundary_find (buffer, NULL,
|
||||
GIMP_BOUNDARY_WITHIN_BOUNDS,
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#define _O_BINARY 0
|
||||
#endif
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gegl.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
|
@ -291,7 +291,8 @@ gimp_brush_load_brush (GimpContext *context,
|
|||
NULL);
|
||||
g_free (name);
|
||||
|
||||
brush->mask = temp_buf_new (header.width, header.height, 1);
|
||||
brush->mask = temp_buf_new (header.width, header.height,
|
||||
babl_format ("Y u8"));
|
||||
|
||||
mask = temp_buf_get_data (brush->mask);
|
||||
size = header.width * header.height * header.bytes;
|
||||
|
@ -345,7 +346,8 @@ gimp_brush_load_brush (GimpContext *context,
|
|||
{
|
||||
guchar buf[8 * 1024];
|
||||
|
||||
brush->pixmap = temp_buf_new (header.width, header.height, 3);
|
||||
brush->pixmap = temp_buf_new (header.width, header.height,
|
||||
babl_format ("R'G'B' u8"));
|
||||
pixmap = temp_buf_get_data (brush->pixmap);
|
||||
|
||||
for (i = 0; success && i < size;)
|
||||
|
@ -648,7 +650,7 @@ gimp_brush_load_abr_brush_v12 (FILE *file,
|
|||
brush->x_axis.y = 0.0;
|
||||
brush->y_axis.x = 0.0;
|
||||
brush->y_axis.y = height / 2.0;
|
||||
brush->mask = temp_buf_new (width, height, 1);
|
||||
brush->mask = temp_buf_new (width, height, babl_format ("Y u8"));
|
||||
|
||||
mask = temp_buf_get_data (brush->mask);
|
||||
size = width * height * bytes;
|
||||
|
@ -755,7 +757,7 @@ gimp_brush_load_abr_brush_v6 (FILE *file,
|
|||
brush->x_axis.y = 0.0;
|
||||
brush->y_axis.x = 0.0;
|
||||
brush->y_axis.y = height / 2.0;
|
||||
brush->mask = temp_buf_new (width, height, 1);
|
||||
brush->mask = temp_buf_new (width, height, babl_format ("Y u8"));
|
||||
|
||||
mask = temp_buf_get_data (brush->mask);
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ gimp_brush_real_transform_mask (GimpBrush *brush,
|
|||
gimp_matrix3_translate (&matrix, -x, -y);
|
||||
gimp_matrix3_invert (&matrix);
|
||||
|
||||
result = temp_buf_new (dest_width, dest_height, 1);
|
||||
result = temp_buf_new (dest_width, dest_height, babl_format ("Y u8"));
|
||||
|
||||
dest = temp_buf_get_data (result);
|
||||
src = temp_buf_get_data (source);
|
||||
|
@ -342,10 +342,9 @@ gimp_brush_real_transform_mask (GimpBrush *brush,
|
|||
|
||||
blur_src = temp_buf_copy (result);
|
||||
|
||||
src_buffer = gimp_temp_buf_create_buffer (blur_src, babl_format ("Y u8"),
|
||||
TRUE);
|
||||
dest_buffer = gimp_temp_buf_create_buffer (blur_src, babl_format ("Y u8"),
|
||||
FALSE);
|
||||
src_buffer = gimp_temp_buf_create_buffer (blur_src, TRUE);
|
||||
dest_buffer = gimp_temp_buf_create_buffer (blur_src, FALSE);
|
||||
|
||||
gimp_gegl_convolve (src_buffer,
|
||||
GEGL_RECTANGLE (0, 0,
|
||||
blur_src->width,
|
||||
|
@ -486,7 +485,7 @@ gimp_brush_real_transform_pixmap (GimpBrush *brush,
|
|||
gimp_matrix3_translate (&matrix, -x, -y);
|
||||
gimp_matrix3_invert (&matrix);
|
||||
|
||||
result = temp_buf_new (dest_width, dest_height, 3);
|
||||
result = temp_buf_new (dest_width, dest_height, babl_format ("R'G'B' u8"));
|
||||
|
||||
dest = temp_buf_get_data (result);
|
||||
src = temp_buf_get_data (source);
|
||||
|
@ -643,8 +642,8 @@ gimp_brush_real_transform_pixmap (GimpBrush *brush,
|
|||
|
||||
blur_src = temp_buf_copy (result);
|
||||
|
||||
src_buffer = gimp_temp_buf_create_buffer (blur_src, NULL, TRUE);
|
||||
dest_buffer = gimp_temp_buf_create_buffer (blur_src, NULL, FALSE);
|
||||
src_buffer = gimp_temp_buf_create_buffer (blur_src, TRUE);
|
||||
dest_buffer = gimp_temp_buf_create_buffer (blur_src, FALSE);
|
||||
|
||||
gimp_gegl_convolve (src_buffer,
|
||||
GEGL_RECTANGLE (0, 0,
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <cairo.h>
|
||||
#include <gegl.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
|
@ -314,7 +314,7 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
|
|||
|
||||
if (! mask_buf)
|
||||
{
|
||||
mask_buf = temp_buf_new (1, 1, 1);
|
||||
mask_buf = temp_buf_new (1, 1, babl_format ("Y u8"));
|
||||
temp_buf_data_clear ((TempBuf *) mask_buf);
|
||||
free_mask = TRUE;
|
||||
}
|
||||
|
@ -330,7 +330,8 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
|
|||
}
|
||||
}
|
||||
|
||||
return_buf = temp_buf_new (mask_width, mask_height, 4);
|
||||
return_buf = temp_buf_new (mask_width, mask_height,
|
||||
babl_format ("R'G'B'A u8"));
|
||||
temp_buf_data_clear (return_buf);
|
||||
|
||||
mask = temp_buf_get_data (mask_buf);
|
||||
|
|
|
@ -203,16 +203,15 @@ gimp_brush_clipboard_buffer_changed (Gimp *gimp,
|
|||
width = MIN (gimp_buffer_get_width (gimp->global_buffer), 512);
|
||||
height = MIN (gimp_buffer_get_height (gimp->global_buffer), 512);
|
||||
|
||||
brush->mask = temp_buf_new (width, height, 1);
|
||||
brush->pixmap = temp_buf_new (width, height, 3);
|
||||
brush->mask = temp_buf_new (width, height, babl_format ("Y u8"));
|
||||
brush->pixmap = temp_buf_new (width, height, babl_format ("R'G'B' u8"));
|
||||
|
||||
/* copy the alpha channel into the brush's mask */
|
||||
if (babl_format_has_alpha (format))
|
||||
{
|
||||
dest_buffer = gimp_temp_buf_create_buffer (brush->mask,
|
||||
babl_format ("A u8"),
|
||||
FALSE);
|
||||
dest_buffer = gimp_temp_buf_create_buffer (brush->mask, FALSE);
|
||||
|
||||
gegl_buffer_set_format (dest_buffer, babl_format ("A u8"));
|
||||
gegl_buffer_copy (buffer, NULL, dest_buffer, NULL);
|
||||
|
||||
g_object_unref (dest_buffer);
|
||||
|
@ -224,7 +223,7 @@ gimp_brush_clipboard_buffer_changed (Gimp *gimp,
|
|||
}
|
||||
|
||||
/* copy the color channels into the brush's pixmap */
|
||||
dest_buffer = gimp_temp_buf_create_buffer (brush->pixmap, NULL, FALSE);
|
||||
dest_buffer = gimp_temp_buf_create_buffer (brush->pixmap, FALSE);
|
||||
|
||||
gegl_buffer_copy (buffer, NULL, dest_buffer, NULL);
|
||||
|
||||
|
@ -235,7 +234,7 @@ gimp_brush_clipboard_buffer_changed (Gimp *gimp,
|
|||
width = 17;
|
||||
height = 17;
|
||||
|
||||
brush->mask = temp_buf_new (width, height, 1);
|
||||
brush->mask = temp_buf_new (width, height, babl_format ("Y u8"));
|
||||
temp_buf_data_clear (brush->mask);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gegl.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gegl.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gegl.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
|
@ -483,7 +483,8 @@ gimp_brush_generated_calc (GimpBrushGenerated *brush,
|
|||
&s, &c, &x_axis, &y_axis);
|
||||
|
||||
mask = temp_buf_new (half_width * 2 + 1,
|
||||
half_height * 2 + 1, 1);
|
||||
half_height * 2 + 1,
|
||||
babl_format ("Y u8"));
|
||||
|
||||
centerp = temp_buf_get_data (mask) + half_height * mask->width + half_width;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#define _O_BINARY 0
|
||||
#endif
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gegl.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gegl.h>
|
||||
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
|
||||
|
|
|
@ -196,11 +196,9 @@ gimp_buffer_get_new_preview (GimpViewable *viewable,
|
|||
gint height)
|
||||
{
|
||||
GimpBuffer *buffer = GIMP_BUFFER (viewable);
|
||||
const Babl *format = gimp_buffer_get_format (buffer);
|
||||
TempBuf *preview;
|
||||
|
||||
preview = temp_buf_new (width, height,
|
||||
babl_format_get_bytes_per_pixel (format));
|
||||
preview = temp_buf_new (width, height, gimp_buffer_get_format (buffer));
|
||||
|
||||
gegl_buffer_get (buffer->buffer, NULL,
|
||||
MIN ((gdouble) width / (gdouble) gimp_buffer_get_width (buffer),
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
|
||||
#include "config/gimpcoreconfig.h"
|
||||
|
||||
#include "gegl/gimp-gegl-utils.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpchannel.h"
|
||||
#include "gimpimage.h"
|
||||
|
@ -218,7 +220,8 @@ gimp_drawable_indexed_preview (GimpDrawable *drawable,
|
|||
src_x, src_y, src_width, src_height,
|
||||
FALSE);
|
||||
|
||||
preview_buf = temp_buf_new (dest_width, dest_height, bytes);
|
||||
preview_buf = temp_buf_new (dest_width, dest_height,
|
||||
gimp_bpp_to_babl_format (bytes));
|
||||
|
||||
pixel_region_init_temp_buf (&destPR, preview_buf,
|
||||
0, 0, dest_width, dest_height);
|
||||
|
|
|
@ -220,7 +220,7 @@ gimp_gradient_get_new_preview (GimpViewable *viewable,
|
|||
cur_x += dx;
|
||||
}
|
||||
|
||||
temp_buf = temp_buf_new (width, height, 4);
|
||||
temp_buf = temp_buf_new (width, height, babl_format ("R'G'B'A u8"));
|
||||
|
||||
buf = temp_buf_get_data (temp_buf);
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ gimp_palette_get_new_preview (GimpViewable *viewable,
|
|||
gint cell_size;
|
||||
gint x, y;
|
||||
|
||||
temp_buf = temp_buf_new (width, height, 3);
|
||||
temp_buf = temp_buf_new (width, height, babl_format ("R'G'B' u8"));
|
||||
memset (temp_buf_get_data (temp_buf), 255, width * height * 3);
|
||||
|
||||
if (palette->n_columns > 1)
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gegl.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
|
@ -49,6 +49,8 @@
|
|||
|
||||
#include "base/temp-buf.h"
|
||||
|
||||
#include "gegl/gimp-gegl-utils.h"
|
||||
|
||||
#include "gimppattern.h"
|
||||
#include "gimppattern-header.h"
|
||||
#include "gimppattern-load.h"
|
||||
|
@ -154,7 +156,9 @@ gimp_pattern_load (GimpContext *context,
|
|||
|
||||
g_free (name);
|
||||
|
||||
pattern->mask = temp_buf_new (header.width, header.height, header.bytes);
|
||||
pattern->mask = temp_buf_new (header.width, header.height,
|
||||
gimp_bpp_to_babl_format (header.bytes));
|
||||
|
||||
if (read (fd, temp_buf_get_data (pattern->mask),
|
||||
header.width * header.height * header.bytes) <
|
||||
header.width * header.height * header.bytes)
|
||||
|
@ -186,14 +190,9 @@ gimp_pattern_load_pixbuf (GimpContext *context,
|
|||
{
|
||||
GimpPattern *pattern;
|
||||
GdkPixbuf *pixbuf;
|
||||
guchar *pat_data;
|
||||
guchar *buf_data;
|
||||
GeglBuffer *src_buffer;
|
||||
GeglBuffer *dest_buffer;
|
||||
gchar *name;
|
||||
gint width;
|
||||
gint height;
|
||||
gint bytes;
|
||||
gint rowstride;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (filename != NULL, NULL);
|
||||
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
|
||||
|
@ -218,21 +217,18 @@ gimp_pattern_load_pixbuf (GimpContext *context,
|
|||
NULL);
|
||||
g_free (name);
|
||||
|
||||
width = gdk_pixbuf_get_width (pixbuf);
|
||||
height = gdk_pixbuf_get_height (pixbuf);
|
||||
bytes = gdk_pixbuf_get_n_channels (pixbuf);
|
||||
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
|
||||
pattern->mask =
|
||||
temp_buf_new (gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf),
|
||||
gimp_bpp_to_babl_format (gdk_pixbuf_get_n_channels (pixbuf)));
|
||||
|
||||
pattern->mask = temp_buf_new (width, height, bytes);
|
||||
src_buffer = gimp_pixbuf_create_buffer (pixbuf);
|
||||
dest_buffer = gimp_temp_buf_create_buffer (pattern->mask, FALSE);
|
||||
|
||||
pat_data = gdk_pixbuf_get_pixels (pixbuf);
|
||||
buf_data = temp_buf_get_data (pattern->mask);
|
||||
gegl_buffer_copy (src_buffer, NULL, dest_buffer, NULL);
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
memcpy (buf_data + i * width * bytes, pat_data, width * bytes);
|
||||
pat_data += rowstride;
|
||||
}
|
||||
g_object_unref (src_buffer);
|
||||
g_object_unref (dest_buffer);
|
||||
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
|
|
|
@ -155,10 +155,10 @@ gimp_pattern_get_new_preview (GimpViewable *viewable,
|
|||
copy_height = MIN (height, pattern->mask->height);
|
||||
|
||||
temp_buf = temp_buf_new (copy_width, copy_height,
|
||||
pattern->mask->bytes);
|
||||
pattern->mask->format);
|
||||
|
||||
src_buffer = gimp_temp_buf_create_buffer (pattern->mask, NULL, FALSE);
|
||||
dest_buffer = gimp_temp_buf_create_buffer (temp_buf, NULL, FALSE);
|
||||
src_buffer = gimp_temp_buf_create_buffer (pattern->mask, FALSE);
|
||||
dest_buffer = gimp_temp_buf_create_buffer (temp_buf, FALSE);
|
||||
|
||||
gegl_buffer_copy (src_buffer, GEGL_RECTANGLE (0, 0, copy_width, copy_height),
|
||||
dest_buffer, GEGL_RECTANGLE (0, 0, 0, 0));
|
||||
|
@ -232,7 +232,7 @@ gimp_pattern_new (GimpContext *context,
|
|||
"name", name,
|
||||
NULL);
|
||||
|
||||
pattern->mask = temp_buf_new (32, 32, 3);
|
||||
pattern->mask = temp_buf_new (32, 32, babl_format ("R'G'B' u8"));
|
||||
|
||||
data = temp_buf_get_data (pattern->mask);
|
||||
|
||||
|
@ -278,5 +278,5 @@ gimp_pattern_create_buffer (const GimpPattern *pattern)
|
|||
{
|
||||
g_return_val_if_fail (GIMP_IS_PATTERN (pattern), NULL);
|
||||
|
||||
return gimp_temp_buf_create_buffer (pattern->mask, NULL, FALSE);
|
||||
return gimp_temp_buf_create_buffer (pattern->mask, FALSE);
|
||||
}
|
||||
|
|
|
@ -189,16 +189,14 @@ gimp_pattern_clipboard_buffer_changed (Gimp *gimp,
|
|||
if (gimp->global_buffer)
|
||||
{
|
||||
GimpBuffer *buffer = gimp->global_buffer;
|
||||
const Babl *format = gimp_buffer_get_format (buffer);
|
||||
gint width;
|
||||
gint height;
|
||||
gint bytes;
|
||||
|
||||
width = MIN (gimp_buffer_get_width (buffer), 512);
|
||||
height = MIN (gimp_buffer_get_height (buffer), 512);
|
||||
bytes = babl_format_get_bytes_per_pixel (format);
|
||||
|
||||
pattern->mask = temp_buf_new (width, height, bytes);
|
||||
pattern->mask = temp_buf_new (width, height,
|
||||
gimp_buffer_get_format (buffer));
|
||||
|
||||
gegl_buffer_get (gimp_buffer_get_buffer (buffer),
|
||||
GEGL_RECTANGLE (0, 0, width, height), 1.0,
|
||||
|
@ -208,7 +206,7 @@ gimp_pattern_clipboard_buffer_changed (Gimp *gimp,
|
|||
}
|
||||
else
|
||||
{
|
||||
pattern->mask = temp_buf_new (16, 16, 3);
|
||||
pattern->mask = temp_buf_new (16, 16, babl_format ("R'G'B' u8"));
|
||||
memset (temp_buf_get_data (pattern->mask), 255, 16 * 16 * 3);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gegl.h>
|
||||
|
||||
#include "core-types.h"
|
||||
|
||||
|
@ -215,6 +215,7 @@ gimp_preview_cache_get (GSList **plist,
|
|||
gdouble y_ratio;
|
||||
guchar *src_data;
|
||||
guchar *dest_data;
|
||||
gint bytes;
|
||||
gint loop1;
|
||||
gint loop2;
|
||||
|
||||
|
@ -228,7 +229,7 @@ gimp_preview_cache_get (GSList **plist,
|
|||
pheight = pn.buf->height;
|
||||
|
||||
/* Now get the real one and add to cache */
|
||||
preview = temp_buf_new (width, height, pn.buf->bytes);
|
||||
preview = temp_buf_new (width, height, pn.buf->format);
|
||||
|
||||
/* preview from nearest bigger one */
|
||||
if (width)
|
||||
|
@ -244,6 +245,8 @@ gimp_preview_cache_get (GSList **plist,
|
|||
src_data = temp_buf_get_data (pn.buf);
|
||||
dest_data = temp_buf_get_data (preview);
|
||||
|
||||
bytes = babl_format_get_bytes_per_pixel (preview->format);
|
||||
|
||||
for (loop1 = 0 ; loop1 < height ; loop1++)
|
||||
for (loop2 = 0 ; loop2 < width ; loop2++)
|
||||
{
|
||||
|
@ -252,13 +255,13 @@ gimp_preview_cache_get (GSList **plist,
|
|||
guchar *dest_pixel;
|
||||
|
||||
src_pixel = src_data +
|
||||
((gint) (loop2 * x_ratio)) * preview->bytes +
|
||||
((gint) (loop1 * y_ratio)) * pwidth * preview->bytes;
|
||||
((gint) (loop2 * x_ratio)) * bytes +
|
||||
((gint) (loop1 * y_ratio)) * pwidth * bytes;
|
||||
|
||||
dest_pixel = dest_data +
|
||||
(loop2 + loop1 * width) * preview->bytes;
|
||||
(loop2 + loop1 * width) * bytes;
|
||||
|
||||
for (i = 0; i < preview->bytes; i++)
|
||||
for (i = 0; i < bytes; i++)
|
||||
*dest_pixel++ = *src_pixel++;
|
||||
}
|
||||
|
||||
|
|
|
@ -359,12 +359,12 @@ gimp_viewable_real_get_new_pixbuf (GimpViewable *viewable,
|
|||
GeglBuffer *dest_buffer;
|
||||
|
||||
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
|
||||
temp_buf->bytes == 4 || temp_buf->bytes == 2,
|
||||
babl_format_has_alpha (temp_buf->format),
|
||||
8,
|
||||
temp_buf->width,
|
||||
temp_buf->height);
|
||||
|
||||
src_buffer = gimp_temp_buf_create_buffer (temp_buf, NULL, FALSE);
|
||||
src_buffer = gimp_temp_buf_create_buffer (temp_buf, FALSE);
|
||||
dest_buffer = gimp_pixbuf_create_buffer (pixbuf);
|
||||
|
||||
gegl_buffer_copy (src_buffer, NULL, dest_buffer, NULL);
|
||||
|
@ -812,7 +812,7 @@ gimp_viewable_get_dummy_preview (GimpViewable *viewable,
|
|||
|
||||
pixbuf = gimp_viewable_get_dummy_pixbuf (viewable, width, height, bpp);
|
||||
|
||||
buf = temp_buf_new (width, height, bpp);
|
||||
buf = temp_buf_new (width, height, gimp_bpp_to_babl_format (bpp));
|
||||
|
||||
src = gdk_pixbuf_get_pixels (pixbuf);
|
||||
dest = temp_buf_get_data (buf);
|
||||
|
|
|
@ -247,29 +247,19 @@ gimp_gegl_buffer_get_tiles (GeglBuffer *buffer)
|
|||
|
||||
GeglBuffer *
|
||||
gimp_temp_buf_create_buffer (TempBuf *temp_buf,
|
||||
const Babl *format,
|
||||
gboolean take_ownership)
|
||||
{
|
||||
GeglBuffer *buffer;
|
||||
gint width, height, bytes;
|
||||
|
||||
g_return_val_if_fail (temp_buf != NULL, NULL);
|
||||
g_return_val_if_fail (format == NULL ||
|
||||
babl_format_get_bytes_per_pixel (format) ==
|
||||
temp_buf->bytes, NULL);
|
||||
|
||||
width = temp_buf->width;
|
||||
height = temp_buf->height;
|
||||
bytes = temp_buf->bytes;
|
||||
|
||||
if (! format)
|
||||
format = gimp_bpp_to_babl_format (bytes);
|
||||
|
||||
buffer =
|
||||
gegl_buffer_linear_new_from_data (temp_buf_get_data (temp_buf),
|
||||
format,
|
||||
GEGL_RECTANGLE (0, 0, width, height),
|
||||
width * bytes,
|
||||
temp_buf->format,
|
||||
GEGL_RECTANGLE (0, 0,
|
||||
temp_buf->width,
|
||||
temp_buf->height),
|
||||
GEGL_AUTO_ROWSTRIDE,
|
||||
take_ownership ?
|
||||
(GDestroyNotify) temp_buf_free : NULL,
|
||||
take_ownership ?
|
||||
|
|
|
@ -42,7 +42,6 @@ GeglBuffer * gimp_tile_manager_create_buffer (TileManager *tm,
|
|||
TileManager * gimp_gegl_buffer_get_tiles (GeglBuffer *buffer);
|
||||
|
||||
GeglBuffer * gimp_temp_buf_create_buffer (TempBuf *temp_buf,
|
||||
const Babl *format,
|
||||
gboolean take_ownership);
|
||||
TempBuf * gimp_gegl_buffer_get_temp_buf (GeglBuffer *buffer);
|
||||
|
||||
|
|
|
@ -828,10 +828,9 @@ gimp_brush_core_get_paint_buffer (GimpPaintCore *paint_core,
|
|||
if ((x2 - x1) && (y2 - y1))
|
||||
{
|
||||
const Babl *format = gimp_drawable_get_format_with_alpha (drawable);
|
||||
gint bytes = babl_format_get_bytes_per_pixel (format);
|
||||
TempBuf *temp_buf;
|
||||
|
||||
temp_buf = temp_buf_new ((x2 - x1), (y2 - y1), bytes);
|
||||
temp_buf = temp_buf_new ((x2 - x1), (y2 - y1), format);
|
||||
|
||||
*paint_buffer_x = x1;
|
||||
*paint_buffer_y = y1;
|
||||
|
@ -839,8 +838,7 @@ gimp_brush_core_get_paint_buffer (GimpPaintCore *paint_core,
|
|||
if (paint_core->paint_buffer)
|
||||
g_object_unref (paint_core->paint_buffer);
|
||||
|
||||
paint_core->paint_buffer = gimp_temp_buf_create_buffer (temp_buf, format,
|
||||
TRUE);
|
||||
paint_core->paint_buffer = gimp_temp_buf_create_buffer (temp_buf, TRUE);
|
||||
|
||||
return paint_core->paint_buffer;
|
||||
}
|
||||
|
@ -946,9 +944,7 @@ gimp_brush_core_paste_canvas (GimpBrushCore *core,
|
|||
off_x = (x < 0) ? -x : 0;
|
||||
off_y = (y < 0) ? -y : 0;
|
||||
|
||||
paint_mask = gimp_temp_buf_create_buffer ((TempBuf *) brush_mask,
|
||||
babl_format ("Y u8"),
|
||||
FALSE);
|
||||
paint_mask = gimp_temp_buf_create_buffer ((TempBuf *) brush_mask, FALSE);
|
||||
|
||||
gimp_paint_core_paste (paint_core, paint_mask,
|
||||
GEGL_RECTANGLE (off_x, off_y,
|
||||
|
@ -997,9 +993,7 @@ gimp_brush_core_replace_canvas (GimpBrushCore *core,
|
|||
off_x = (x < 0) ? -x : 0;
|
||||
off_y = (y < 0) ? -y : 0;
|
||||
|
||||
paint_mask = gimp_temp_buf_create_buffer ((TempBuf *) brush_mask,
|
||||
babl_format ("Y u8"),
|
||||
FALSE);
|
||||
paint_mask = gimp_temp_buf_create_buffer ((TempBuf *) brush_mask, FALSE);
|
||||
|
||||
gimp_paint_core_replace (paint_core, paint_mask,
|
||||
GEGL_RECTANGLE (off_x, off_y,
|
||||
|
@ -1127,7 +1121,8 @@ gimp_brush_core_subsample_mask (GimpBrushCore *core,
|
|||
}
|
||||
|
||||
dest = temp_buf_new (mask->width + 2,
|
||||
mask->height + 2, 1);
|
||||
mask->height + 2,
|
||||
babl_format ("Y u8"));
|
||||
temp_buf_data_clear (dest);
|
||||
|
||||
/* Allocate and initialize the accum buffer */
|
||||
|
@ -1207,7 +1202,8 @@ gimp_brush_core_pressurize_mask (GimpBrushCore *core,
|
|||
temp_buf_free (core->pressure_brush);
|
||||
|
||||
core->pressure_brush = temp_buf_new (brush_mask->width + 2,
|
||||
brush_mask->height + 2, 1);
|
||||
brush_mask->height + 2,
|
||||
babl_format ("Y u8"));
|
||||
temp_buf_data_clear (core->pressure_brush);
|
||||
|
||||
#ifdef FANCY_PRESSURE
|
||||
|
@ -1347,7 +1343,8 @@ gimp_brush_core_solidify_mask (GimpBrushCore *core,
|
|||
}
|
||||
|
||||
dest = temp_buf_new (brush_mask->width + 2,
|
||||
brush_mask->height + 2, 1);
|
||||
brush_mask->height + 2,
|
||||
babl_format ("Y u8"));
|
||||
temp_buf_data_clear (dest);
|
||||
|
||||
core->solid_brushes[dest_offset_y][dest_offset_x] = dest;
|
||||
|
@ -1622,6 +1619,7 @@ gimp_brush_core_paint_line_pixmap_mask (GimpImage *dest,
|
|||
gint width,
|
||||
GimpBrushApplicationMode mode)
|
||||
{
|
||||
gint pixmap_bytes;
|
||||
guchar *b;
|
||||
|
||||
/* Make sure x, y are positive */
|
||||
|
@ -1630,20 +1628,22 @@ gimp_brush_core_paint_line_pixmap_mask (GimpImage *dest,
|
|||
while (y < 0)
|
||||
y += pixmap_mask->height;
|
||||
|
||||
pixmap_bytes = babl_format_get_bytes_per_pixel (pixmap_mask->format);
|
||||
|
||||
/* Point to the approriate scanline */
|
||||
b = (temp_buf_get_data (pixmap_mask) +
|
||||
(y % pixmap_mask->height) * pixmap_mask->width * pixmap_mask->bytes);
|
||||
(y % pixmap_mask->height) * pixmap_mask->width * pixmap_bytes);
|
||||
|
||||
if (mode == GIMP_BRUSH_SOFT && brush_mask)
|
||||
{
|
||||
const Babl *fish;
|
||||
const guchar *mask = (temp_buf_get_data (brush_mask) +
|
||||
(y % brush_mask->height) * brush_mask->width);
|
||||
guchar *line_buf = g_alloca (width * (pixmap_mask->bytes + 1));
|
||||
guchar *line_buf = g_alloca (width * (pixmap_bytes + 1));
|
||||
guchar *l = line_buf;
|
||||
gint i;
|
||||
|
||||
fish = babl_fish (gimp_bpp_to_babl_format_with_alpha (pixmap_mask->bytes),
|
||||
fish = babl_fish (gimp_bpp_to_babl_format_with_alpha (pixmap_bytes),
|
||||
gimp_drawable_get_format_with_alpha (drawable));
|
||||
|
||||
/* put the source pixmap's pixels, plus the mask's alpha, into
|
||||
|
@ -1653,7 +1653,7 @@ gimp_brush_core_paint_line_pixmap_mask (GimpImage *dest,
|
|||
for (i = 0; i < width; i++)
|
||||
{
|
||||
gint x_index = ((i + x) % pixmap_mask->width);
|
||||
gint p_bytes = pixmap_mask->bytes;
|
||||
gint p_bytes = pixmap_bytes;
|
||||
guchar *p = b + x_index * p_bytes;
|
||||
|
||||
while (p_bytes--)
|
||||
|
@ -1667,11 +1667,11 @@ gimp_brush_core_paint_line_pixmap_mask (GimpImage *dest,
|
|||
else
|
||||
{
|
||||
const Babl *fish;
|
||||
guchar *line_buf = g_alloca (width * (pixmap_mask->bytes));
|
||||
guchar *line_buf = g_alloca (width * (pixmap_bytes));
|
||||
guchar *l = line_buf;
|
||||
gint i;
|
||||
|
||||
fish = babl_fish (gimp_bpp_to_babl_format (pixmap_mask->bytes),
|
||||
fish = babl_fish (gimp_bpp_to_babl_format (pixmap_bytes),
|
||||
gimp_drawable_get_format_with_alpha (drawable));
|
||||
|
||||
/* put the source pixmap's pixels, into one line, so we can use
|
||||
|
@ -1680,7 +1680,7 @@ gimp_brush_core_paint_line_pixmap_mask (GimpImage *dest,
|
|||
for (i = 0; i < width; i++)
|
||||
{
|
||||
gint x_index = ((i + x) % pixmap_mask->width);
|
||||
gint p_bytes = pixmap_mask->bytes;
|
||||
gint p_bytes = pixmap_bytes;
|
||||
guchar *p = b + x_index * p_bytes;
|
||||
|
||||
while (p_bytes--)
|
||||
|
|
|
@ -136,7 +136,6 @@ gimp_convolve_motion (GimpPaintCore *paint_core,
|
|||
GeglBuffer *paint_buffer;
|
||||
gint paint_buffer_x;
|
||||
gint paint_buffer_y;
|
||||
const Babl *format;
|
||||
TempBuf *convolve_temp;
|
||||
GeglBuffer *convolve_buffer;
|
||||
gdouble fade_point;
|
||||
|
@ -182,13 +181,11 @@ gimp_convolve_motion (GimpPaintCore *paint_core,
|
|||
brush_core->brush->mask->height / 2,
|
||||
rate);
|
||||
|
||||
format = gegl_buffer_get_format (paint_buffer);
|
||||
|
||||
convolve_temp = temp_buf_new (gegl_buffer_get_width (paint_buffer),
|
||||
gegl_buffer_get_height (paint_buffer),
|
||||
babl_format_get_bytes_per_pixel (format));
|
||||
gegl_buffer_get_format (paint_buffer));
|
||||
|
||||
convolve_buffer = gimp_temp_buf_create_buffer (convolve_temp, format, TRUE);
|
||||
convolve_buffer = gimp_temp_buf_create_buffer (convolve_temp, TRUE);
|
||||
|
||||
gegl_buffer_copy (gimp_drawable_get_buffer (drawable),
|
||||
GEGL_RECTANGLE (paint_buffer_x,
|
||||
|
|
|
@ -537,8 +537,7 @@ gimp_heal_motion (GimpSourceCore *source_core,
|
|||
paint_area_width,
|
||||
paint_area_height));
|
||||
|
||||
mask_buffer = gimp_temp_buf_create_buffer ((TempBuf *) mask_buf,
|
||||
NULL, FALSE);
|
||||
mask_buffer = gimp_temp_buf_create_buffer ((TempBuf *) mask_buf, FALSE);
|
||||
|
||||
gimp_heal (src_copy,
|
||||
GEGL_RECTANGLE (0, 0,
|
||||
|
|
|
@ -221,10 +221,9 @@ gimp_ink_get_paint_buffer (GimpPaintCore *paint_core,
|
|||
if ((x2 - x1) && (y2 - y1))
|
||||
{
|
||||
const Babl *format = gimp_drawable_get_format_with_alpha (drawable);
|
||||
gint bytes = babl_format_get_bytes_per_pixel (format);
|
||||
TempBuf *temp_buf;
|
||||
|
||||
temp_buf = temp_buf_new ((x2 - x1), (y2 - y1), bytes);
|
||||
temp_buf = temp_buf_new ((x2 - x1), (y2 - y1), format);
|
||||
|
||||
*paint_buffer_x = x1;
|
||||
*paint_buffer_y = y1;
|
||||
|
@ -232,8 +231,7 @@ gimp_ink_get_paint_buffer (GimpPaintCore *paint_core,
|
|||
if (paint_core->paint_buffer)
|
||||
g_object_unref (paint_core->paint_buffer);
|
||||
|
||||
paint_core->paint_buffer = gimp_temp_buf_create_buffer (temp_buf, format,
|
||||
TRUE);
|
||||
paint_core->paint_buffer = gimp_temp_buf_create_buffer (temp_buf, TRUE);
|
||||
|
||||
return paint_core->paint_buffer;
|
||||
}
|
||||
|
|
|
@ -186,12 +186,9 @@ gimp_smudge_start (GimpPaintCore *paint_core,
|
|||
|
||||
/* Allocate the accumulation buffer */
|
||||
accum_temp = temp_buf_new (accum_size, accum_size,
|
||||
gimp_drawable_bytes (drawable));
|
||||
gimp_drawable_get_format (drawable));
|
||||
|
||||
smudge->accum_buffer =
|
||||
gimp_temp_buf_create_buffer (accum_temp,
|
||||
gimp_drawable_get_format (drawable),
|
||||
TRUE);
|
||||
smudge->accum_buffer = gimp_temp_buf_create_buffer (accum_temp, TRUE);
|
||||
|
||||
/* adjust the x and y coordinates to the upper left corner of the
|
||||
* accumulator
|
||||
|
|
|
@ -279,8 +279,8 @@ brush_get_info_invoker (GimpProcedure *procedure,
|
|||
{
|
||||
width = brush->mask->width;
|
||||
height = brush->mask->height;
|
||||
mask_bpp = brush->mask->bytes;
|
||||
color_bpp = brush->pixmap ? brush->pixmap->bytes : 0;
|
||||
mask_bpp = babl_format_get_bytes_per_pixel (brush->mask->format);
|
||||
color_bpp = brush->pixmap ? babl_format_get_bytes_per_pixel (brush->pixmap->format) : 0;
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
|
@ -330,16 +330,15 @@ brush_get_pixels_invoker (GimpProcedure *procedure,
|
|||
{
|
||||
width = brush->mask->width;
|
||||
height = brush->mask->height;
|
||||
mask_bpp = brush->mask->bytes;
|
||||
num_mask_bytes = brush->mask->height * brush->mask->width *
|
||||
brush->mask->bytes;
|
||||
mask_bpp = babl_format_get_bytes_per_pixel (brush->mask->format);
|
||||
num_mask_bytes = brush->mask->height * brush->mask->width * mask_bpp;
|
||||
mask_bytes = g_memdup (temp_buf_get_data (brush->mask), num_mask_bytes);
|
||||
|
||||
if (brush->pixmap)
|
||||
{
|
||||
color_bpp = brush->pixmap->bytes;
|
||||
color_bpp = babl_format_get_bytes_per_pixel (brush->pixmap->format);
|
||||
num_color_bytes = brush->pixmap->height * brush->pixmap->width *
|
||||
brush->pixmap->bytes;
|
||||
color_bpp;
|
||||
color_bytes = g_memdup (temp_buf_get_data (brush->pixmap),
|
||||
num_color_bytes);
|
||||
}
|
||||
|
|
|
@ -747,8 +747,8 @@ drawable_thumbnail_invoker (GimpProcedure *procedure,
|
|||
{
|
||||
actual_width = buf->width;
|
||||
actual_height = buf->height;
|
||||
bpp = buf->bytes;
|
||||
thumbnail_data_count = actual_width * actual_height * bpp;
|
||||
bpp = babl_format_get_bytes_per_pixel (buf->format);
|
||||
thumbnail_data_count = temp_buf_get_data_size (buf);
|
||||
thumbnail_data = g_memdup (temp_buf_get_data (buf),
|
||||
thumbnail_data_count);
|
||||
|
||||
|
@ -827,8 +827,8 @@ drawable_sub_thumbnail_invoker (GimpProcedure *procedure,
|
|||
{
|
||||
width = buf->width;
|
||||
height = buf->height;
|
||||
bpp = buf->bytes;
|
||||
thumbnail_data_count = buf->height * buf->width * buf->bytes;
|
||||
bpp = babl_format_get_bytes_per_pixel (buf->format);
|
||||
thumbnail_data_count = temp_buf_get_data_size (buf);
|
||||
thumbnail_data = g_memdup (temp_buf_get_data (buf),
|
||||
thumbnail_data_count);
|
||||
|
||||
|
|
|
@ -1714,8 +1714,8 @@ image_thumbnail_invoker (GimpProcedure *procedure,
|
|||
{
|
||||
actual_width = buf->width;
|
||||
actual_height = buf->height;
|
||||
bpp = buf->bytes;
|
||||
thumbnail_data_count = actual_width * actual_height * bpp;
|
||||
bpp = babl_format_get_bytes_per_pixel (buf->format);
|
||||
thumbnail_data_count = temp_buf_get_data_size (buf);
|
||||
thumbnail_data = g_memdup (temp_buf_get_data (buf),
|
||||
thumbnail_data_count);
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ pattern_get_info_invoker (GimpProcedure *procedure,
|
|||
{
|
||||
width = pattern->mask->width;
|
||||
height = pattern->mask->height;
|
||||
bpp = pattern->mask->bytes;
|
||||
bpp = babl_format_get_bytes_per_pixel (pattern->mask->format);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
|
@ -108,9 +108,8 @@ pattern_get_pixels_invoker (GimpProcedure *procedure,
|
|||
{
|
||||
width = pattern->mask->width;
|
||||
height = pattern->mask->height;
|
||||
bpp = pattern->mask->bytes;
|
||||
num_color_bytes = pattern->mask->height * pattern->mask->width *
|
||||
pattern->mask->bytes;
|
||||
bpp = babl_format_get_bytes_per_pixel (pattern->mask->format);
|
||||
num_color_bytes = temp_buf_get_data_size (pattern->mask);
|
||||
color_bytes = g_memdup (temp_buf_get_data (pattern->mask),
|
||||
num_color_bytes);
|
||||
}
|
||||
|
|
|
@ -158,9 +158,8 @@ patterns_get_pattern_data_invoker (GimpProcedure *procedure,
|
|||
actual_name = g_strdup (gimp_object_get_name (pattern));
|
||||
width = pattern->mask->width;
|
||||
height = pattern->mask->height;
|
||||
mask_bpp = pattern->mask->bytes;
|
||||
length = pattern->mask->height * pattern->mask->width *
|
||||
pattern->mask->bytes;
|
||||
mask_bpp = babl_format_get_bytes_per_pixel (pattern->mask->format);
|
||||
length = temp_buf_get_data_size (pattern->mask);
|
||||
mask_data = g_memdup (temp_buf_get_data (pattern->mask), length);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gegl.h>
|
||||
|
||||
#include <pango/pangocairo.h>
|
||||
|
||||
|
@ -283,7 +283,7 @@ gimp_font_get_new_preview (GimpViewable *viewable,
|
|||
|
||||
width = cairo_format_stride_for_width (CAIRO_FORMAT_A8, width);
|
||||
|
||||
temp_buf = temp_buf_new (width, height, 1);
|
||||
temp_buf = temp_buf_new (width, height, babl_format ("Y' u8"));
|
||||
memset (temp_buf_get_data (temp_buf), 255, width * height);
|
||||
|
||||
surface = cairo_image_surface_create_for_data (temp_buf_get_data (temp_buf),
|
||||
|
|
|
@ -1338,7 +1338,7 @@ calculate_curve (GimpIscissorsTool *iscissors,
|
|||
if (iscissors->dp_buf)
|
||||
temp_buf_free (iscissors->dp_buf);
|
||||
|
||||
iscissors->dp_buf = temp_buf_new (width, height, 4);
|
||||
iscissors->dp_buf = temp_buf_new (width, height, babl_format ("Y u32"));
|
||||
|
||||
/* find the optimal path of pixels from (x1, y1) to (x2, y2) */
|
||||
find_optimal_path (iscissors->gradient_map, iscissors->dp_buf,
|
||||
|
|
|
@ -55,7 +55,7 @@ gimp_vectors_get_new_preview (GimpViewable *viewable,
|
|||
xscale = ((gdouble) width) / gimp_image_get_width (gimp_item_get_image (item));
|
||||
yscale = ((gdouble) height) / gimp_image_get_height (gimp_item_get_image (item));
|
||||
|
||||
temp_buf = temp_buf_new (width, height, 1);
|
||||
temp_buf = temp_buf_new (width, height, babl_format ("Y' u8"));
|
||||
data = temp_buf_get_data (temp_buf);
|
||||
memset (data, 255, width * height);
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ gimp_pattern_select_run_callback (GimpPdbDialog *dialog,
|
|||
G_TYPE_STRING, gimp_object_get_name (object),
|
||||
GIMP_TYPE_INT32, pattern->mask->width,
|
||||
GIMP_TYPE_INT32, pattern->mask->height,
|
||||
GIMP_TYPE_INT32, pattern->mask->bytes,
|
||||
GIMP_TYPE_INT32, babl_format_get_bytes_per_pixel (pattern->mask->format),
|
||||
GIMP_TYPE_INT32, array->length,
|
||||
GIMP_TYPE_INT8_ARRAY, array,
|
||||
GIMP_TYPE_INT32, closing,
|
||||
|
|
|
@ -931,6 +931,7 @@ gimp_view_render_temp_buf_to_surface (TempBuf *temp_buf,
|
|||
gint i, j;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
gint bytes;
|
||||
gint rowstride;
|
||||
gint dest_stride;
|
||||
gboolean color;
|
||||
|
@ -969,10 +970,11 @@ gimp_view_render_temp_buf_to_surface (TempBuf *temp_buf,
|
|||
* 3) If image is gray, then temp_buf should have bytes == {1, 2}
|
||||
*/
|
||||
|
||||
color = (temp_buf->bytes == 3 || temp_buf->bytes == 4);
|
||||
has_alpha = (temp_buf->bytes == 2 || temp_buf->bytes == 4);
|
||||
bytes = babl_format_get_bytes_per_pixel (temp_buf->format);
|
||||
color = (bytes == 3 || bytes == 4);
|
||||
has_alpha = babl_format_has_alpha (temp_buf->format);
|
||||
render_composite = (channel == -1);
|
||||
rowstride = temp_buf->width * temp_buf->bytes;
|
||||
rowstride = temp_buf->width * bytes;
|
||||
|
||||
/* render the checkerboard only if the temp_buf has alpha *and*
|
||||
* we render a composite view
|
||||
|
@ -1015,7 +1017,7 @@ gimp_view_render_temp_buf_to_surface (TempBuf *temp_buf,
|
|||
y2 = CLAMP (temp_buf->y + temp_buf->height, 0, dest_height);
|
||||
|
||||
src = temp_buf_get_data (temp_buf) + ((y1 - temp_buf->y) * rowstride +
|
||||
(x1 - temp_buf->x) * temp_buf->bytes);
|
||||
(x1 - temp_buf->x) * bytes);
|
||||
|
||||
for (i = 0; i < dest_height; i++)
|
||||
{
|
||||
|
@ -1048,7 +1050,7 @@ gimp_view_render_temp_buf_to_surface (TempBuf *temp_buf,
|
|||
}
|
||||
|
||||
/* The stuff in the middle */
|
||||
for (j = x1; j < x2; j++, d += 4, s += temp_buf->bytes)
|
||||
for (j = x1; j < x2; j++, d += 4, s += bytes)
|
||||
{
|
||||
if (has_alpha && render_composite)
|
||||
{
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include "base/temp-buf.h"
|
||||
|
||||
#include "gegl/gimp-gegl-utils.h"
|
||||
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpdrawable-preview.h"
|
||||
#include "core/gimpimage.h"
|
||||
|
@ -166,7 +168,8 @@ gimp_view_renderer_drawable_render (GimpViewRenderer *renderer,
|
|||
{
|
||||
gint bytes = gimp_drawable_preview_bytes (drawable);
|
||||
|
||||
render_buf = temp_buf_new (1, 1, bytes);
|
||||
render_buf = temp_buf_new (1, 1,
|
||||
gimp_bpp_to_babl_format (bytes));
|
||||
temp_buf_data_clear (render_buf);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -243,8 +243,8 @@ HELP
|
|||
{
|
||||
width = brush->mask->width;
|
||||
height = brush->mask->height;
|
||||
mask_bpp = brush->mask->bytes;
|
||||
color_bpp = brush->pixmap ? brush->pixmap->bytes : 0;
|
||||
mask_bpp = babl_format_get_bytes_per_pixel (brush->mask->format);
|
||||
color_bpp = brush->pixmap ? babl_format_get_bytes_per_pixel (brush->pixmap->format) : 0;
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
|
@ -294,16 +294,15 @@ HELP
|
|||
{
|
||||
width = brush->mask->width;
|
||||
height = brush->mask->height;
|
||||
mask_bpp = brush->mask->bytes;
|
||||
num_mask_bytes = brush->mask->height * brush->mask->width *
|
||||
brush->mask->bytes;
|
||||
mask_bpp = babl_format_get_bytes_per_pixel (brush->mask->format);
|
||||
num_mask_bytes = brush->mask->height * brush->mask->width * mask_bpp;
|
||||
mask_bytes = g_memdup (temp_buf_get_data (brush->mask), num_mask_bytes);
|
||||
|
||||
if (brush->pixmap)
|
||||
{
|
||||
color_bpp = brush->pixmap->bytes;
|
||||
color_bpp = babl_format_get_bytes_per_pixel (brush->pixmap->format);
|
||||
num_color_bytes = brush->pixmap->height * brush->pixmap->width *
|
||||
brush->pixmap->bytes;
|
||||
color_bpp;
|
||||
color_bytes = g_memdup (temp_buf_get_data (brush->pixmap),
|
||||
num_color_bytes);
|
||||
}
|
||||
|
|
|
@ -731,8 +731,8 @@ HELP
|
|||
{
|
||||
actual_width = buf->width;
|
||||
actual_height = buf->height;
|
||||
bpp = buf->bytes;
|
||||
thumbnail_data_count = actual_width * actual_height * bpp;
|
||||
bpp = babl_format_get_bytes_per_pixel (buf->format);
|
||||
thumbnail_data_count = temp_buf_get_data_size (buf);
|
||||
thumbnail_data = g_memdup (temp_buf_get_data (buf),
|
||||
thumbnail_data_count);
|
||||
|
||||
|
@ -812,8 +812,8 @@ HELP
|
|||
{
|
||||
width = buf->width;
|
||||
height = buf->height;
|
||||
bpp = buf->bytes;
|
||||
thumbnail_data_count = buf->height * buf->width * buf->bytes;
|
||||
bpp = babl_format_get_bytes_per_pixel (buf->format);
|
||||
thumbnail_data_count = temp_buf_get_data_size (buf);
|
||||
thumbnail_data = g_memdup (temp_buf_get_data (buf),
|
||||
thumbnail_data_count);
|
||||
|
||||
|
|
|
@ -2862,8 +2862,8 @@ HELP
|
|||
{
|
||||
actual_width = buf->width;
|
||||
actual_height = buf->height;
|
||||
bpp = buf->bytes;
|
||||
thumbnail_data_count = actual_width * actual_height * bpp;
|
||||
bpp = babl_format_get_bytes_per_pixel (buf->format);
|
||||
thumbnail_data_count = temp_buf_get_data_size (buf);
|
||||
thumbnail_data = g_memdup (temp_buf_get_data (buf),
|
||||
thumbnail_data_count);
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ HELP
|
|||
{
|
||||
width = pattern->mask->width;
|
||||
height = pattern->mask->height;
|
||||
bpp = pattern->mask->bytes;
|
||||
bpp = babl_format_get_bytes_per_pixel (pattern->mask->format);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
|
@ -97,9 +97,8 @@ HELP
|
|||
{
|
||||
width = pattern->mask->width;
|
||||
height = pattern->mask->height;
|
||||
bpp = pattern->mask->bytes;
|
||||
num_color_bytes = pattern->mask->height * pattern->mask->width *
|
||||
pattern->mask->bytes;
|
||||
bpp = babl_format_get_bytes_per_pixel (pattern->mask->format);
|
||||
num_color_bytes = temp_buf_get_data_size (pattern->mask);
|
||||
color_bytes = g_memdup (temp_buf_get_data (pattern->mask),
|
||||
num_color_bytes);
|
||||
}
|
||||
|
|
|
@ -136,9 +136,8 @@ sub patterns_get_pattern_data {
|
|||
actual_name = g_strdup (gimp_object_get_name (pattern));
|
||||
width = pattern->mask->width;
|
||||
height = pattern->mask->height;
|
||||
mask_bpp = pattern->mask->bytes;
|
||||
length = pattern->mask->height * pattern->mask->width *
|
||||
pattern->mask->bytes;
|
||||
mask_bpp = babl_format_get_bytes_per_pixel (pattern->mask->format);
|
||||
length = temp_buf_get_data_size (pattern->mask);
|
||||
mask_data = g_memdup (temp_buf_get_data (pattern->mask), length);
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue