placed all the orientation map-related public functions in orientmap.h.
* plug-ins/gimpressionist/: placed all the orientation map-related public functions in orientmap.h. Now we're freeing the PPM's that it is allocating by a call to orientation_map_free_resources().
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
2004-07-25 Shlomi Fish <shlomif@iglu.org.il>
|
||||||
|
|
||||||
|
* plug-ins/gimpressionist/: placed all the orientation map-related
|
||||||
|
public functions in orientmap.h. Now we're freeing the PPM's that it
|
||||||
|
is allocating by a call to orientation_map_free_resources().
|
||||||
|
|
||||||
2004-07-26 Michael Natterer <mitch@gimp.org>
|
2004-07-26 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
* app/tools/gimpeditselectiontool.[ch]: renamed init_edit_selection()
|
* app/tools/gimpeditselectiontool.[ch]: renamed init_edit_selection()
|
||||||
|
@ -40,6 +40,7 @@ gimpressionist_sources = \
|
|||||||
infile.h \
|
infile.h \
|
||||||
orientation.h \
|
orientation.h \
|
||||||
orientation.c \
|
orientation.c \
|
||||||
|
orientmap.h \
|
||||||
orientmap.c \
|
orientmap.c \
|
||||||
paper.c \
|
paper.c \
|
||||||
paper.h \
|
paper.h \
|
||||||
|
@ -204,7 +204,7 @@ static void
|
|||||||
savebrush (GtkWidget *wg,
|
savebrush (GtkWidget *wg,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
static GtkWidget *dialog = NULL;
|
GtkWidget *dialog = NULL;
|
||||||
GList *thispath = parsepath ();
|
GList *thispath = parsepath ();
|
||||||
gchar *path;
|
gchar *path;
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "brush.h"
|
#include "brush.h"
|
||||||
#include "presets.h"
|
#include "presets.h"
|
||||||
#include "random.h"
|
#include "random.h"
|
||||||
|
#include "orientmap.h"
|
||||||
|
|
||||||
|
|
||||||
#include "libgimp/stdplugins-intl.h"
|
#include "libgimp/stdplugins-intl.h"
|
||||||
@ -200,6 +201,7 @@ run (const gchar *name,
|
|||||||
preview_free_resources();
|
preview_free_resources();
|
||||||
brush_free();
|
brush_free();
|
||||||
preset_free();
|
preset_free();
|
||||||
|
orientation_map_free_resources();
|
||||||
|
|
||||||
values[0].data.d_status = status;
|
values[0].data.d_status = status;
|
||||||
|
|
||||||
|
@ -133,8 +133,6 @@ GtkWidget *create_one_column_list (GtkWidget *parent,
|
|||||||
|
|
||||||
void brush_reload (const gchar *fn, struct ppm *p);
|
void brush_reload (const gchar *fn, struct ppm *p);
|
||||||
|
|
||||||
void create_orientmap_dialog (void);
|
|
||||||
void update_orientmap_dialog (void);
|
|
||||||
double get_direction (double x, double y, int from);
|
double get_direction (double x, double y, int from);
|
||||||
|
|
||||||
void create_sizemap_dialog (void);
|
void create_sizemap_dialog (void);
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "gimpressionist.h"
|
#include "gimpressionist.h"
|
||||||
#include "orientation.h"
|
#include "orientation.h"
|
||||||
|
#include "orientmap.h"
|
||||||
|
|
||||||
#include "libgimp/stdplugins-intl.h"
|
#include "libgimp/stdplugins-intl.h"
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
#include "preview.h"
|
#include "preview.h"
|
||||||
|
|
||||||
|
#include "orientmap.h"
|
||||||
|
|
||||||
#include "libgimp/stdplugins-intl.h"
|
#include "libgimp/stdplugins-intl.h"
|
||||||
|
|
||||||
#define NUMVECTYPES 4
|
#define NUMVECTYPES 4
|
||||||
@ -124,18 +126,19 @@ double get_direction (double x, double y, int from)
|
|||||||
return 90-(gimp_rad_to_deg(atan2(dy,dx))+angoff);
|
return 90-(gimp_rad_to_deg(atan2(dy,dx))+angoff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ppm_t update_om_preview_nbuffer = {0,0,NULL};
|
||||||
|
|
||||||
static void update_orient_map_preview_prev (void)
|
static void update_orient_map_preview_prev (void)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
static ppm_t nbuffer = {0,0,NULL};
|
|
||||||
guchar black[3] = {0,0,0};
|
guchar black[3] = {0,0,0};
|
||||||
guchar gray[3] = {120,120,120};
|
guchar gray[3] = {120,120,120};
|
||||||
guchar white[3] = {255,255,255};
|
guchar white[3] = {255,255,255};
|
||||||
|
|
||||||
if (!PPM_IS_INITED (&nbuffer))
|
if (!PPM_IS_INITED (&update_om_preview_nbuffer))
|
||||||
ppm_new (&nbuffer,OMWIDTH,OMHEIGHT);
|
ppm_new (&update_om_preview_nbuffer,OMWIDTH,OMHEIGHT);
|
||||||
|
|
||||||
fill (&nbuffer, black);
|
fill (&update_om_preview_nbuffer, black);
|
||||||
|
|
||||||
for (y = 6; y < OMHEIGHT-4; y += 10)
|
for (y = 6; y < OMHEIGHT-4; y += 10)
|
||||||
for (x = 6; x < OMWIDTH-4; x += 10)
|
for (x = 6; x < OMWIDTH-4; x += 10)
|
||||||
@ -143,13 +146,15 @@ static void update_orient_map_preview_prev (void)
|
|||||||
double dir = gimp_deg_to_rad(get_direction(x/(double)OMWIDTH,y/(double)OMHEIGHT,0));
|
double dir = gimp_deg_to_rad(get_direction(x/(double)OMWIDTH,y/(double)OMHEIGHT,0));
|
||||||
double xo = sin(dir)*4.0;
|
double xo = sin(dir)*4.0;
|
||||||
double yo = cos(dir)*4.0;
|
double yo = cos(dir)*4.0;
|
||||||
ppm_drawline (&nbuffer, x-xo, y-yo, x+xo, y+yo, gray);
|
ppm_drawline (&update_om_preview_nbuffer, x-xo, y-yo, x+xo,
|
||||||
ppm_put_rgb (&nbuffer, x-xo, y-yo, white);
|
y+yo, gray);
|
||||||
|
ppm_put_rgb (&update_om_preview_nbuffer, x-xo, y-yo, white);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (y = 0; y < OMHEIGHT; y++)
|
for (y = 0; y < OMHEIGHT; y++)
|
||||||
gtk_preview_draw_row (GTK_PREVIEW (orient_map_preview_prev),
|
gtk_preview_draw_row (GTK_PREVIEW (orient_map_preview_prev),
|
||||||
(guchar *) nbuffer.col + y * OMWIDTH * 3, 0, y,
|
(guchar *) update_om_preview_nbuffer.col +
|
||||||
|
y * OMWIDTH * 3, 0, y,
|
||||||
OMWIDTH);
|
OMWIDTH);
|
||||||
|
|
||||||
gtk_widget_queue_draw (orient_map_preview_prev);
|
gtk_widget_queue_draw (orient_map_preview_prev);
|
||||||
@ -162,10 +167,11 @@ static void update_orient_map_preview_prev (void)
|
|||||||
|
|
||||||
static int selectedvector = 0;
|
static int selectedvector = 0;
|
||||||
|
|
||||||
|
static ppm_t update_vector_preview_backup = {0,0,NULL};
|
||||||
|
static ppm_t update_vector_preview_buffer = {0,0,NULL};
|
||||||
|
|
||||||
static void update_vector_prev(void)
|
static void update_vector_prev(void)
|
||||||
{
|
{
|
||||||
static ppm_t backup = {0,0,NULL};
|
|
||||||
static ppm_t buffer = {0,0,NULL};
|
|
||||||
static int ok = 0;
|
static int ok = 0;
|
||||||
int i, x, y;
|
int i, x, y;
|
||||||
double dir, xo, yo;
|
double dir, xo, yo;
|
||||||
@ -181,13 +187,14 @@ static void update_vector_prev(void)
|
|||||||
val = 0.5;
|
val = 0.5;
|
||||||
|
|
||||||
if (!ok || (val != last_val)) {
|
if (!ok || (val != last_val)) {
|
||||||
infile_copy_to_ppm (&backup);
|
infile_copy_to_ppm (&update_vector_preview_backup);
|
||||||
ppm_apply_brightness (&backup, val, 1,1,1);
|
ppm_apply_brightness (&update_vector_preview_backup, val, 1,1,1);
|
||||||
if ((backup.width != OMWIDTH) || (backup.height != OMHEIGHT))
|
if ((update_vector_preview_backup.width != OMWIDTH) ||
|
||||||
resize_fast (&backup, OMWIDTH, OMHEIGHT);
|
(update_vector_preview_backup.height != OMHEIGHT))
|
||||||
|
resize_fast (&update_vector_preview_backup, OMWIDTH, OMHEIGHT);
|
||||||
ok = 1;
|
ok = 1;
|
||||||
}
|
}
|
||||||
ppm_copy (&backup, &buffer);
|
ppm_copy (&update_vector_preview_backup, &update_vector_preview_buffer);
|
||||||
|
|
||||||
for(i = 0; i < num_vectors; i++) {
|
for(i = 0; i < num_vectors; i++) {
|
||||||
double s;
|
double s;
|
||||||
@ -198,20 +205,29 @@ static void update_vector_prev(void)
|
|||||||
xo = sin(dir)*(6.0+100*s);
|
xo = sin(dir)*(6.0+100*s);
|
||||||
yo = cos(dir)*(6.0+100*s);
|
yo = cos(dir)*(6.0+100*s);
|
||||||
if(i == selectedvector)
|
if(i == selectedvector)
|
||||||
ppm_drawline (&buffer, x-xo, y-yo, x+xo, y+yo, red);
|
ppm_drawline (&update_vector_preview_buffer, x-xo, y-yo, x+xo,
|
||||||
|
y+yo, red);
|
||||||
else
|
else
|
||||||
ppm_drawline (&buffer, x-xo, y-yo, x+xo, y+yo, gray);
|
ppm_drawline (&update_vector_preview_buffer, x-xo, y-yo,
|
||||||
ppm_put_rgb (&buffer, x-xo, y-yo, white);
|
x+xo, y+yo, gray);
|
||||||
|
ppm_put_rgb (&update_vector_preview_buffer, x-xo, y-yo, white);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (y = 0; y < OMHEIGHT; y++)
|
for (y = 0; y < OMHEIGHT; y++)
|
||||||
gtk_preview_draw_row (GTK_PREVIEW (vector_preview),
|
gtk_preview_draw_row (GTK_PREVIEW (vector_preview),
|
||||||
(guchar *) buffer.col + y * OMWIDTH * 3,
|
(guchar *) update_vector_preview_buffer.col +
|
||||||
|
y * OMWIDTH * 3,
|
||||||
0, y, OMWIDTH);
|
0, y, OMWIDTH);
|
||||||
|
|
||||||
gtk_widget_queue_draw (vector_preview);
|
gtk_widget_queue_draw (vector_preview);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void orientation_map_free_resources()
|
||||||
|
{
|
||||||
|
ppm_kill(&update_om_preview_nbuffer);
|
||||||
|
ppm_kill(&update_vector_preview_backup);
|
||||||
|
ppm_kill(&update_vector_preview_buffer);
|
||||||
|
}
|
||||||
static gboolean adjignore = FALSE;
|
static gboolean adjignore = FALSE;
|
||||||
|
|
||||||
static void update_slides(void)
|
static void update_slides(void)
|
||||||
|
7
plug-ins/gimpressionist/orientmap.h
Normal file
7
plug-ins/gimpressionist/orientmap.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#ifndef __ORIENTMAP_H
|
||||||
|
#define __ORIENTMAP_H
|
||||||
|
void create_orientmap_dialog (void);
|
||||||
|
void update_orientmap_dialog (void);
|
||||||
|
void orientation_map_free_resources(void);
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user