mirror of https://github.com/GNOME/gimp.git
added gimp_channel_new_from_component() which creates a new GimpChannel
2003-03-12 Sven Neumann <sven@gimp.org> * app/core/gimpchannel.[ch]: added gimp_channel_new_from_component() which creates a new GimpChannel from an image's color component. * app/gui/channels-commands.[ch]: added channels_duplicate_component_cmd_callback(). * app/paint-funcs/paint-funcs-generic.h * app/paint-funcs/paint-funcs.[ch]: added code to extract a color component from a PixelRegion (untested!). * plug-ins/common/checkerboard.c: cosmetics.
This commit is contained in:
parent
833a02bdeb
commit
3c30a90bdb
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2003-03-12 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/core/gimpchannel.[ch]: added gimp_channel_new_from_component()
|
||||
which creates a new GimpChannel from an image's color component.
|
||||
|
||||
* app/gui/channels-commands.[ch]: added
|
||||
channels_duplicate_component_cmd_callback().
|
||||
|
||||
* app/paint-funcs/paint-funcs-generic.h
|
||||
* app/paint-funcs/paint-funcs.[ch]: added code to extract a color
|
||||
component from a PixelRegion (untested!).
|
||||
|
||||
* plug-ins/common/checkerboard.c: cosmetics.
|
||||
|
||||
2003-03-11 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimpimagefile.c (gimp_imagefile_create_thumbnail),
|
||||
|
|
|
@ -541,6 +541,25 @@ channels_edit_channel_query (GimpChannel *channel)
|
|||
gtk_widget_show (options->query_box);
|
||||
}
|
||||
|
||||
void
|
||||
channels_duplicate_component_cmd_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
GimpChannel *channel;
|
||||
GimpRGB color;
|
||||
return_if_no_image (gimage, data);
|
||||
|
||||
gimp_rgba_set (&color, 0, 0, 0, 0.5);
|
||||
|
||||
/* FIXME: hardcoded component */
|
||||
channel = gimp_channel_new_from_component (gimage, GIMP_RED_CHANNEL,
|
||||
"Component Copy",
|
||||
&color);
|
||||
|
||||
gimp_image_add_channel (gimage, channel, -1);
|
||||
gimp_image_flush (gimage);
|
||||
}
|
||||
|
||||
/* private functions */
|
||||
|
||||
|
|
|
@ -46,5 +46,8 @@ void channels_new_channel_query (GimpImage *gimage,
|
|||
gboolean interactive);
|
||||
void channels_edit_channel_query (GimpChannel *channel);
|
||||
|
||||
void channels_duplicate_component_cmd_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
#endif /* __CHANNELS_COMMANDS_H__ */
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "paint-funcs/paint-funcs.h"
|
||||
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-projection.h"
|
||||
#include "gimpimage-undo-push.h"
|
||||
#include "gimpchannel.h"
|
||||
#include "gimplayer.h"
|
||||
|
@ -272,6 +273,58 @@ gimp_channel_new (GimpImage *gimage,
|
|||
return channel;
|
||||
}
|
||||
|
||||
GimpChannel *
|
||||
gimp_channel_new_from_component (GimpImage *gimage,
|
||||
GimpChannelType type,
|
||||
const gchar *name,
|
||||
const GimpRGB *color)
|
||||
{
|
||||
GimpChannel *channel;
|
||||
TileManager *projection;
|
||||
PixelRegion src;
|
||||
PixelRegion dest;
|
||||
gint width;
|
||||
gint height;
|
||||
gint pixel = -1;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case GIMP_RED_CHANNEL: pixel = RED_PIX; break;
|
||||
case GIMP_GREEN_CHANNEL: pixel = GREEN_PIX; break;
|
||||
case GIMP_BLUE_CHANNEL: pixel = BLUE_PIX; break;
|
||||
case GIMP_GRAY_CHANNEL: pixel = GRAY_PIX; break;
|
||||
case GIMP_INDEXED_CHANNEL: pixel = INDEXED_PIX; break;
|
||||
case GIMP_ALPHA_CHANNEL:
|
||||
switch (gimp_image_base_type (gimage))
|
||||
{
|
||||
case GIMP_RGB: pixel = ALPHA_PIX; break;
|
||||
case GIMP_GRAY: pixel = ALPHA_G_PIX; break;
|
||||
case GIMP_INDEXED: pixel = ALPHA_I_PIX; break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
g_return_val_if_fail (pixel != -1, NULL);
|
||||
|
||||
projection = gimp_image_projection (gimage);
|
||||
width = tile_manager_width (projection);
|
||||
height = tile_manager_height (projection);
|
||||
|
||||
channel = gimp_channel_new (gimage, width, height, name, color);
|
||||
|
||||
pixel_region_init (&src, projection,
|
||||
0, 0, width, height, FALSE);
|
||||
pixel_region_init (&dest, GIMP_DRAWABLE (channel)->tiles,
|
||||
0, 0, width, height, TRUE);
|
||||
|
||||
copy_component (&src, &dest, pixel);
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_channel_set_color (GimpChannel *channel,
|
||||
const GimpRGB *color)
|
||||
|
|
|
@ -78,6 +78,11 @@ GimpChannel * gimp_channel_new (GimpImage *gimage,
|
|||
const gchar *name,
|
||||
const GimpRGB *color);
|
||||
|
||||
GimpChannel * gimp_channel_new_from_component (GimpImage *gimage,
|
||||
GimpChannelType type,
|
||||
const gchar *name,
|
||||
const GimpRGB *color);
|
||||
|
||||
gdouble gimp_channel_get_opacity (const GimpChannel *channel);
|
||||
void gimp_channel_set_opacity (GimpChannel *channel,
|
||||
gdouble opacity);
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "paint-funcs/paint-funcs.h"
|
||||
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-projection.h"
|
||||
#include "gimpimage-undo-push.h"
|
||||
#include "gimpchannel.h"
|
||||
#include "gimplayer.h"
|
||||
|
@ -272,6 +273,58 @@ gimp_channel_new (GimpImage *gimage,
|
|||
return channel;
|
||||
}
|
||||
|
||||
GimpChannel *
|
||||
gimp_channel_new_from_component (GimpImage *gimage,
|
||||
GimpChannelType type,
|
||||
const gchar *name,
|
||||
const GimpRGB *color)
|
||||
{
|
||||
GimpChannel *channel;
|
||||
TileManager *projection;
|
||||
PixelRegion src;
|
||||
PixelRegion dest;
|
||||
gint width;
|
||||
gint height;
|
||||
gint pixel = -1;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case GIMP_RED_CHANNEL: pixel = RED_PIX; break;
|
||||
case GIMP_GREEN_CHANNEL: pixel = GREEN_PIX; break;
|
||||
case GIMP_BLUE_CHANNEL: pixel = BLUE_PIX; break;
|
||||
case GIMP_GRAY_CHANNEL: pixel = GRAY_PIX; break;
|
||||
case GIMP_INDEXED_CHANNEL: pixel = INDEXED_PIX; break;
|
||||
case GIMP_ALPHA_CHANNEL:
|
||||
switch (gimp_image_base_type (gimage))
|
||||
{
|
||||
case GIMP_RGB: pixel = ALPHA_PIX; break;
|
||||
case GIMP_GRAY: pixel = ALPHA_G_PIX; break;
|
||||
case GIMP_INDEXED: pixel = ALPHA_I_PIX; break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
g_return_val_if_fail (pixel != -1, NULL);
|
||||
|
||||
projection = gimp_image_projection (gimage);
|
||||
width = tile_manager_width (projection);
|
||||
height = tile_manager_height (projection);
|
||||
|
||||
channel = gimp_channel_new (gimage, width, height, name, color);
|
||||
|
||||
pixel_region_init (&src, projection,
|
||||
0, 0, width, height, FALSE);
|
||||
pixel_region_init (&dest, GIMP_DRAWABLE (channel)->tiles,
|
||||
0, 0, width, height, TRUE);
|
||||
|
||||
copy_component (&src, &dest, pixel);
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_channel_set_color (GimpChannel *channel,
|
||||
const GimpRGB *color)
|
||||
|
|
|
@ -78,6 +78,11 @@ GimpChannel * gimp_channel_new (GimpImage *gimage,
|
|||
const gchar *name,
|
||||
const GimpRGB *color);
|
||||
|
||||
GimpChannel * gimp_channel_new_from_component (GimpImage *gimage,
|
||||
GimpChannelType type,
|
||||
const gchar *name,
|
||||
const GimpRGB *color);
|
||||
|
||||
gdouble gimp_channel_get_opacity (const GimpChannel *channel);
|
||||
void gimp_channel_set_opacity (GimpChannel *channel,
|
||||
gdouble opacity);
|
||||
|
|
|
@ -541,6 +541,25 @@ channels_edit_channel_query (GimpChannel *channel)
|
|||
gtk_widget_show (options->query_box);
|
||||
}
|
||||
|
||||
void
|
||||
channels_duplicate_component_cmd_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
GimpChannel *channel;
|
||||
GimpRGB color;
|
||||
return_if_no_image (gimage, data);
|
||||
|
||||
gimp_rgba_set (&color, 0, 0, 0, 0.5);
|
||||
|
||||
/* FIXME: hardcoded component */
|
||||
channel = gimp_channel_new_from_component (gimage, GIMP_RED_CHANNEL,
|
||||
"Component Copy",
|
||||
&color);
|
||||
|
||||
gimp_image_add_channel (gimage, channel, -1);
|
||||
gimp_image_flush (gimage);
|
||||
}
|
||||
|
||||
/* private functions */
|
||||
|
||||
|
|
|
@ -46,5 +46,8 @@ void channels_new_channel_query (GimpImage *gimage,
|
|||
gboolean interactive);
|
||||
void channels_edit_channel_query (GimpChannel *channel);
|
||||
|
||||
void channels_duplicate_component_cmd_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
#endif /* __CHANNELS_COMMANDS_H__ */
|
||||
|
|
|
@ -1562,6 +1562,25 @@ initial_inten_a_pixels (const guchar *src,
|
|||
}
|
||||
}
|
||||
|
||||
inline void
|
||||
component_pixels (const guchar *src,
|
||||
guchar *dest,
|
||||
guint length,
|
||||
guint bytes,
|
||||
guint pixel)
|
||||
{
|
||||
src += pixel;
|
||||
|
||||
while (length --)
|
||||
{
|
||||
*dest = *src;
|
||||
|
||||
src += bytes;
|
||||
dest++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
layer_normal_mode (struct apply_layer_mode_struct *alms)
|
||||
{
|
||||
|
|
|
@ -4182,6 +4182,32 @@ copy_gray_to_region (PixelRegion *src,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
copy_component (PixelRegion *src,
|
||||
PixelRegion *dest,
|
||||
guint pixel)
|
||||
{
|
||||
gint h;
|
||||
guchar *s;
|
||||
guchar *d;
|
||||
void *pr;
|
||||
|
||||
for (pr = pixel_regions_register (2, src, dest);
|
||||
pr != NULL;
|
||||
pr = pixel_regions_process (pr))
|
||||
{
|
||||
s = src->data;
|
||||
d = dest->data;
|
||||
h = src->h;
|
||||
|
||||
while (h --)
|
||||
{
|
||||
component_pixels (s, d, src->w, src->bytes, pixel);
|
||||
s += src->rowstride;
|
||||
d += dest->rowstride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct initial_regions_struct
|
||||
{
|
||||
|
|
|
@ -340,6 +340,10 @@ void combine_mask_and_region (PixelRegion *, PixelRegion *, guint);
|
|||
/* Copy a gray image to an intensity-alpha region */
|
||||
void copy_gray_to_region (PixelRegion *, PixelRegion *);
|
||||
|
||||
/* Copy a component (indexed by pixel) to a 1-byte region */
|
||||
void copy_component (PixelRegion *src,
|
||||
PixelRegion *dest,
|
||||
guint pixel);
|
||||
|
||||
void initial_region (PixelRegion *, PixelRegion *,
|
||||
PixelRegion *, guchar *,
|
||||
|
|
|
@ -63,8 +63,9 @@ static gboolean do_checkerboard_dialog (gint32 image_ID,
|
|||
GimpDrawable *drawable);
|
||||
static void check_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void check_size_update_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
static void check_size_update_callback(GtkWidget * widget, gpointer data);
|
||||
|
||||
GimpPlugInInfo PLUG_IN_INFO =
|
||||
{
|
||||
|
@ -237,7 +238,7 @@ do_checkerboard_pattern (GimpDrawable *drawable)
|
|||
}
|
||||
|
||||
|
||||
if (cvals.size == 0)
|
||||
if (cvals.size < 1)
|
||||
{
|
||||
/* make size 1 to prevent division by zero */
|
||||
cvals.size = 1;
|
||||
|
@ -262,8 +263,8 @@ do_checkerboard_pattern (GimpDrawable *drawable)
|
|||
if (cvals.mode)
|
||||
{
|
||||
/* Psychobilly Mode */
|
||||
val =
|
||||
(inblock (x, cvals.size) == inblock (y, cvals.size)) ? 0 : 1;
|
||||
val = ((inblock (x, cvals.size) == inblock (y, cvals.size))
|
||||
? 0 : 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -273,9 +274,11 @@ do_checkerboard_pattern (GimpDrawable *drawable)
|
|||
*/
|
||||
xp = x / cvals.size;
|
||||
yp = y / cvals.size;
|
||||
|
||||
/* if both even or odd, color sqr */
|
||||
val = ( (xp&1) == (yp&1) ) ? 0 : 1;
|
||||
}
|
||||
|
||||
for (bp = 0; bp < dest_rgn.bpp; bp++)
|
||||
dest[bp] = val ? fg[bp] : bg[bp];
|
||||
|
||||
|
|
Loading…
Reference in New Issue