Commit b0787f40 authored by Manish Singh's avatar Manish Singh

fix for (install-colormap) and splash screen using gtk_preview_reset()

        * app/app_procs.c: fix for (install-colormap) and splash screen
        using gtk_preview_reset()

        * configure.in: on some platforms libXmu doesn't require libSM and
        libICE. configure should know this now.

        * app/gradient.c: corrected WM_CLASS typo

        * plug-ins/gfli/gfli.c: fix for load handler magic

        * plug-ins/gtm/gtm.c: don't use naughty gccisms.

        * plug-ins/gqbist
        * plug-ins/maze: updated from registry

-Yosh
parent 849fa641
Sun Mar 8 17:44:05 PST 1998 Manish Singh <yosh@gimp.org>
* app/app_procs.c: fix for (install-colormap) and splash screen
using gtk_preview_reset()
* configure.in: on some platforms libXmu doesn't require libSM and
libICE. configure should know this now.
* app/gradient.c: corrected WM_CLASS typo
* plug-ins/gfli/gfli.c: fix for load handler magic
* plug-ins/gtm/gtm.c: don't use naughty gccisms.
* plug-ins/gqbist
* plug-ins/maze: updated from registry
Tue Mar 3 01:02:30 1998 Larry Ewing <lewing@discord.isc.tamu.edu>
* app/scale.c: Fixed a long standing bug in the scale factor
......
......@@ -298,6 +298,7 @@ destroy_initialization_status_window(void)
win_initstatus = label1 = label2 = pbar = logo_area = NULL;
logo_pixmap = NULL;
gtk_idle_remove(idle_tag);
gtk_preview_reset (); /* so we can reinit the colormaps */
}
}
......@@ -313,7 +314,6 @@ make_initialization_status_window(void)
{
if (no_interface == FALSE)
{
get_standard_colormaps ();
if (no_splash == FALSE)
{
GtkWidget *vbox;
......@@ -483,6 +483,7 @@ app_init ()
/* Things to do only if there is an interface */
if (no_interface == FALSE)
{
get_standard_colormaps ();
create_toolbox ();
gximage_init ();
render_setup (transparency_type, transparency_size);
......
......@@ -145,7 +145,7 @@ batch_run_cmd (char *cmd)
args[i].value.pdb_float = atof (cmd);
break;
case PDB_STRING:
cmd = strtok (NULL, "\"");
cmd = strtok (NULL, " )");
if (!cmd)
goto error;
......
#/* The GIMP -- an image manipulation program
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
......
......@@ -768,7 +768,7 @@ grad_create_gradient_editor(void)
/* Shell and main vbox */
g_editor->shell = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_wmclass (GTK_WINDOW(g_editor->shell), "gradiet_editor", "Gimp");
gtk_window_set_wmclass (GTK_WINDOW(g_editor->shell), "gradient_editor", "Gimp");
gtk_container_border_width(GTK_CONTAINER(g_editor->shell), 0);
gtk_window_set_title(GTK_WINDOW(g_editor->shell), "Gradient Editor");
gtk_window_position(GTK_WINDOW(g_editor->shell), GTK_WIN_POS_CENTER);
......
......@@ -768,7 +768,7 @@ grad_create_gradient_editor(void)
/* Shell and main vbox */
g_editor->shell = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_wmclass (GTK_WINDOW(g_editor->shell), "gradiet_editor", "Gimp");
gtk_window_set_wmclass (GTK_WINDOW(g_editor->shell), "gradient_editor", "Gimp");
gtk_container_border_width(GTK_CONTAINER(g_editor->shell), 0);
gtk_window_set_title(GTK_WINDOW(g_editor->shell), "Gradient Editor");
gtk_window_position(GTK_WINDOW(g_editor->shell), GTK_WIN_POS_CENTER);
......
#/* The GIMP -- an image manipulation program
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
......
......@@ -768,7 +768,7 @@ grad_create_gradient_editor(void)
/* Shell and main vbox */
g_editor->shell = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_wmclass (GTK_WINDOW(g_editor->shell), "gradiet_editor", "Gimp");
gtk_window_set_wmclass (GTK_WINDOW(g_editor->shell), "gradient_editor", "Gimp");
gtk_container_border_width(GTK_CONTAINER(g_editor->shell), 0);
gtk_window_set_title(GTK_WINDOW(g_editor->shell), "Gradient Editor");
gtk_window_position(GTK_WINDOW(g_editor->shell), GTK_WIN_POS_CENTER);
......
......@@ -768,7 +768,7 @@ grad_create_gradient_editor(void)
/* Shell and main vbox */
g_editor->shell = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_wmclass (GTK_WINDOW(g_editor->shell), "gradiet_editor", "Gimp");
gtk_window_set_wmclass (GTK_WINDOW(g_editor->shell), "gradient_editor", "Gimp");
gtk_container_border_width(GTK_CONTAINER(g_editor->shell), 0);
gtk_window_set_title(GTK_WINDOW(g_editor->shell), "Gradient Editor");
gtk_window_position(GTK_WINDOW(g_editor->shell), GTK_WIN_POS_CENTER);
......
#/* The GIMP -- an image manipulation program
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
......
......@@ -1639,6 +1639,10 @@ xcf_load_layer (XcfInfo *info,
if (!layer_mask)
goto error;
/* set the offsets of the layer_mask */
GIMP_DRAWABLE(layer_mask)->offset_x = GIMP_DRAWABLE(layer)->offset_x;
GIMP_DRAWABLE(layer_mask)->offset_y = GIMP_DRAWABLE(layer)->offset_y;
apply_mask = layer->apply_mask;
edit_mask = layer->edit_mask;
show_mask = layer->show_mask;
......
......@@ -1639,6 +1639,10 @@ xcf_load_layer (XcfInfo *info,
if (!layer_mask)
goto error;
/* set the offsets of the layer_mask */
GIMP_DRAWABLE(layer_mask)->offset_x = GIMP_DRAWABLE(layer)->offset_x;
GIMP_DRAWABLE(layer_mask)->offset_y = GIMP_DRAWABLE(layer)->offset_y;
apply_mask = layer->apply_mask;
edit_mask = layer->edit_mask;
show_mask = layer->show_mask;
......
......@@ -68,10 +68,10 @@ AC_DEFUN(AC_GIMP_CHECK,
LDFLAGS="$saved_ldflags $X_LDFLAGS $X_LIBS"
dnl Dont cache this as it depends on CFLAGS, LDFLAGS, etc
AC_MSG_CHECKING([for gtk >= 0.99.4])
AC_TRY_COMPILE(
AC_MSG_CHECKING([for gtk >= 0.99.5])
AC_TRY_LINK(
[#include <gtk/gtk.h>],
[GtkTooltipsClass tipclass;],
[gtk_preview_reset();],
gtk_found=yes,
gtk_found=no)
AC_MSG_RESULT($gtk_found)
......@@ -122,7 +122,9 @@ dnl Test for Xmu
if test -z "$LIBXMU_LIB"; then
AC_CHECK_LIB(Xmu, XmuClientWindow,
WEBBROWSER="webbrowser"; LIBXMU_LIB='-lXmu -lXt -lSM -lICE',
AC_MSG_WARN(*** webbrowser plug-in will not be built ***), -lXt -lSM -lICE)
AC_CHECK_LIB(Xmu, XmuUpdateMapHints,
WEBBROWSER="webbrowser"; LIBXMU_LIB='-lXmu -lXt',
AC_MSG_WARN(*** webbrowser plug-in will not be built ***), -lXt), -lXt, -lSM, -lICE)
fi
dnl Test for libtiff
......
......@@ -2,6 +2,10 @@
* Written 1997 Jens Ch. Restemeier <jchrr@hrz.uni-bielefeld.de>
* This program is based on an algorithm / article by
* Jrn Loviscach.
*
* It appeared in c't 10/95, page 326 and is called
* "Ausgewrfelt - Moderne Kunst algorithmisch erzeugen".
* (~modern art created with algorithms)
*
* It generates one main formula (the middle button) and 8 variations of it.
* If you select a variation it becomes the new main formula. If you
......@@ -33,6 +37,8 @@
* 1.8 Dscho added transform file load/save, bug-fixes
* 1.9 rewrote renderloop.
* 1.9a fixed a bug.
* 1.9b fixed MAIN()
* 1.10 added optimizer
*/
#include <stdio.h>
......@@ -50,7 +56,7 @@
#define NUM_REGISTERS 6
#define PLUG_IN_NAME "plug_in_qbist"
#define PLUG_IN_VERSION "November 1997, 1.8"
#define PLUG_IN_VERSION "March 1998, 1.10"
#define PREVIEW_SIZE 64
/** types *******************************************************************/
......@@ -116,6 +122,46 @@ void modify_info(s_info *o_info, s_info *n_info)
}
}
/*
* Optimizer
*/
int used_trans_flag[MAX_TRANSFORMS];
int used_reg_flag[NUM_REGISTERS];
void check_last_modified(s_info info, int p, int n)
{
p--;
while ((p>=0) && (info.dest[p]!=n)) p--;
if (p<0)
used_reg_flag[n]=1;
else {
used_trans_flag[p]=1;
check_last_modified(info, p, info.source[p]);
check_last_modified(info, p, info.control[p]);
}
}
void optimize(s_info info)
{
int i;
/* double-arg fix: */
for (i=0; i<MAX_TRANSFORMS; i++) {
used_trans_flag[i]=0;
if (i<NUM_REGISTERS)
used_reg_flag[i]=0;
/* double-arg fix: */
switch (info.transformSequence[i]) {
case ROTATE:
case ROTATE2:
case COMPLEMENT:
info.control[i]=info.dest[i];
break;
}
}
/* check for last modified item */
check_last_modified(info, MAX_TRANSFORMS, 0);
}
void qbist(s_info info, gchar *buffer, int xp, int yp, int num, int width, int height, int bpp)
{
gushort gx;
......@@ -127,14 +173,16 @@ void qbist(s_info info, gchar *buffer, int xp, int yp, int num, int width, int h
for(gx=0; gx<num; gx ++) {
for(i=0; i<NUM_REGISTERS; i++) {
reg[i][0] = ((float)gx+xp) / ((float)(width));
reg[i][1] = ((float)yp) / ((float)(height));
reg[i][2] = ((float)i) / ((float)NUM_REGISTERS);
if (used_reg_flag[i]) {
reg[i][0] = ((float)gx+xp) / ((float)(width));
reg[i][1] = ((float)yp) / ((float)(height));
reg[i][2] = ((float)i) / ((float)NUM_REGISTERS);
}
}
for(i=0;i<MAX_TRANSFORMS; i++) {
sr=info.source[i];cr=info.control[i];dr=info.dest[i];
switch (info.transformSequence[i]) {
if (used_trans_flag[i]) switch (info.transformSequence[i]) {
case PROJECTION: {
gfloat scalarProd;
scalarProd = (reg[sr][0]*reg[cr][0])+(reg[sr][1]*reg[cr][1])+(reg[sr][2]*reg[cr][2]);
......@@ -230,14 +278,14 @@ GParamDef *return_vals = NULL;
int nargs = sizeof(args) / sizeof(args[0]);
int nreturn_vals = 0;
MAIN();
MAIN()
void query(void)
{
gimp_install_procedure(PLUG_IN_NAME,
"Create images based on a random genetic formula",
"This Plug-in is based on an article by "
"Jrn Loviscach. It generates modern art "
"Jrn Loviscach (appeared in c't 10/95, page 326). It generates modern art "
"pictures from a random genetic formula.",
"Jrn Loviscach, Jens Ch. Restemeier",
"Jrn Loviscach, Jens Ch. Restemeier",
......@@ -322,6 +370,8 @@ void run(char *name, int nparams, GParam *param, int *nreturn_vals, GParam **ret
gimp_pixel_rgn_init (&imagePR, drawable, 0,0, img_width, img_height, TRUE, TRUE);
row_data=(guchar *)malloc((sel_x2-sel_x1)*img_bpp);
optimize(qbist_info);
gimp_progress_init ("Qbist ...");
for (row=sel_y1; row<sel_y2; row++) {
qbist(qbist_info, row_data, 0, row, sel_x2-sel_x1, sel_x2-sel_x1, sel_y2-sel_y1, img_bpp);
......@@ -378,6 +428,7 @@ void dialog_update_previews(GtkWidget *widget, gpointer data)
int i, j;
guchar buf[PREVIEW_SIZE * 3];
for (j=0;j<9;j++) {
optimize(info[(j+5) % 9]);
for (i = 0; i < PREVIEW_SIZE; i++) {
qbist(info[(j+5) % 9], buf, 0, i, PREVIEW_SIZE, PREVIEW_SIZE, PREVIEW_SIZE, 3);
gtk_preview_draw_row (GTK_PREVIEW (preview[j]), buf, 0, i, PREVIEW_SIZE);
......@@ -415,23 +466,22 @@ int load_data(char *name)
return(1);
}
void save_data(char *name, int k)
void save_data(char *name)
{
int i=0;
FILE *f;
f=fopen(name, "wb");
for(i=0;i<MAX_TRANSFORMS;i++) PUTMACUSHORT(info[k].transformSequence[i], f);
for(i=0;i<MAX_TRANSFORMS;i++) PUTMACUSHORT(info[k].source[i], f);
for(i=0;i<MAX_TRANSFORMS;i++) PUTMACUSHORT(info[k].control[i], f);
for(i=0;i<MAX_TRANSFORMS;i++) PUTMACUSHORT(info[k].dest[i], f);
for(i=0;i<MAX_TRANSFORMS;i++) PUTMACUSHORT(info[0].transformSequence[i], f);
for(i=0;i<MAX_TRANSFORMS;i++) PUTMACUSHORT(info[0].source[i], f);
for(i=0;i<MAX_TRANSFORMS;i++) PUTMACUSHORT(info[0].control[i], f);
for(i=0;i<MAX_TRANSFORMS;i++) PUTMACUSHORT(info[0].dest[i], f);
fclose(f);
}
void file_selection_save(GtkWidget *widget, GtkWidget *file_select)
{
save_data(gtk_file_selection_get_filename (GTK_FILE_SELECTION(file_select)),
0 /* the middle button */ );
save_data(gtk_file_selection_get_filename (GTK_FILE_SELECTION(file_select)));
gtk_widget_destroy(file_select);
}
......@@ -507,7 +557,7 @@ int dialog_create()
gtk_widget_set_default_colormap (gtk_preview_get_cmap ());
dialog=gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW(dialog), "G-Qbist 1.0");
gtk_window_set_title (GTK_WINDOW(dialog), "G-Qbist 1.10");
gtk_signal_connect (GTK_OBJECT (dialog), "destroy",
(GtkSignalFunc) dialog_close,
NULL);
......@@ -516,7 +566,7 @@ int dialog_create()
gtk_table_set_row_spacings(GTK_TABLE(table), 5);
gtk_table_set_col_spacings(GTK_TABLE(table), 5);
gtk_container_border_width (GTK_CONTAINER (table), 5);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table, TRUE, TRUE, 0);
gtk_widget_show(table);
memcpy((char *)&(info[0]), (char *)&qbist_info, sizeof(s_info));
......
......@@ -193,14 +193,19 @@ save_image (char *filename,
{
int row,col, cols, rows, x, y;
int colcount, colspan, rowspan;
int palloc[drawable->width][drawable->height];
/* This works only in gcc - not allowed according */
/* to ANSI C */
/*int palloc[drawable->width][drawable->height];*/
int *palloc;
guchar *buffer, *buf2;
guchar *width, *height;
GPixelRgn pixel_rgn;
char *name;
FILE *fp, *fopen();
palloc = malloc(drawable->width * drawable->height * sizeof(int));
fp = fopen(filename, "w");
if (gtmvals.fulldoc) {
fprintf (fp,"<HTML>\n<HEAD><TITLE>%s</TITLE></HEAD>\n<BODY>\n",filename);
......@@ -239,7 +244,7 @@ save_image (char *filename,
for (row=0; row < rows; row++)
for (col=0; col < cols; col++)
palloc[col][row]=1;
palloc[drawable->width * row + col]=1;
colspan=0;
rowspan=0;
......@@ -259,8 +264,8 @@ save_image (char *filename,
rowspan=0;
gimp_pixel_rgn_get_pixel(&pixel_rgn, buf2, col, row);
while (color_comp(buffer,buf2) && palloc[col][row] == 1 && row < drawable->height) {
while (color_comp(buffer,buf2) && palloc[col][row] == 1 && col < drawable->width ) {
while (color_comp(buffer,buf2) && palloc[drawable->width * row + col] == 1 && row < drawable->height) {
while (color_comp(buffer,buf2) && palloc[drawable->width * row + col] == 1 && col < drawable->width ) {
colcount++;
col++;
gimp_pixel_rgn_get_pixel(&pixel_rgn, buf2, col, row);
......@@ -282,18 +287,18 @@ save_image (char *filename,
if (colspan > 1 || rowspan > 1) {
for (row=0; row < rowspan; row++)
for (col=0; col < colspan; col++)
palloc[col+x][row+y]=0;
palloc[x][y]=2;
palloc[drawable->width * (row+y) + (col+x)]=0;
palloc[drawable->width * y + x]=2;
}
}
if (palloc[x][y]==1)
if (palloc[drawable->width * y + x]==1)
fprintf (fp," <TD%s%sBGCOLOR=#%02x%02x%02x>",width,height,buffer[0],buffer[1],buffer[2]);
if (palloc[x][y]==2)
if (palloc[drawable->width * y + x]==2)
fprintf (fp," <TD ROWSPAN=\"%d\" COLSPAN=\"%d\"%s%sBGCOLOR=#%02x%02x%02x>",rowspan,colspan,width,height,buffer[0],buffer[1],buffer[2]);
if (palloc[x][y]!=0) {
if (palloc[drawable->width * y + x]!=0) {
if (gtmvals.tdcomp)
fprintf (fp,"%s</TD>\n",gtmvals.cellcontent);
else
......@@ -312,6 +317,8 @@ save_image (char *filename,
free(width);
free(height);
free(palloc);
return 1;
}
......
......@@ -107,7 +107,7 @@ query ()
nload_args, nload_return_vals,
load_args, load_return_vals);
gimp_register_magic_load_handler ("file_fli_load", "fli,flc", "", "5,byte,175 ");
gimp_register_magic_load_handler ("file_fli_load", "fli,flc", "", "4,short,0x11af,4,short,0x12af");
}
static void
......
......@@ -2,6 +2,10 @@
* Written 1997 Jens Ch. Restemeier <jchrr@hrz.uni-bielefeld.de>
* This program is based on an algorithm / article by
* Jrn Loviscach.
*
* It appeared in c't 10/95, page 326 and is called
* "Ausgewrfelt - Moderne Kunst algorithmisch erzeugen".
* (~modern art created with algorithms)
*
* It generates one main formula (the middle button) and 8 variations of it.
* If you select a variation it becomes the new main formula. If you
......@@ -33,6 +37,8 @@
* 1.8 Dscho added transform file load/save, bug-fixes
* 1.9 rewrote renderloop.
* 1.9a fixed a bug.
* 1.9b fixed MAIN()
* 1.10 added optimizer
*/
#include <stdio.h>
......@@ -50,7 +56,7 @@
#define NUM_REGISTERS 6
#define PLUG_IN_NAME "plug_in_qbist"
#define PLUG_IN_VERSION "November 1997, 1.8"
#define PLUG_IN_VERSION "March 1998, 1.10"
#define PREVIEW_SIZE 64
/** types *******************************************************************/
......@@ -116,6 +122,46 @@ void modify_info(s_info *o_info, s_info *n_info)
}
}
/*
* Optimizer
*/
int used_trans_flag[MAX_TRANSFORMS];
int used_reg_flag[NUM_REGISTERS];
void check_last_modified(s_info info, int p, int n)
{
p--;
while ((p>=0) && (info.dest[p]!=n)) p--;
if (p<0)
used_reg_flag[n]=1;
else {
used_trans_flag[p]=1;
check_last_modified(info, p, info.source[p]);
check_last_modified(info, p, info.control[p]);
}
}
void optimize(s_info info)
{
int i;
/* double-arg fix: */
for (i=0; i<MAX_TRANSFORMS; i++) {
used_trans_flag[i]=0;
if (i<NUM_REGISTERS)
used_reg_flag[i]=0;
/* double-arg fix: */
switch (info.transformSequence[i]) {
case ROTATE:
case ROTATE2:
case COMPLEMENT:
info.control[i]=info.dest[i];
break;
}
}
/* check for last modified item */
check_last_modified(info, MAX_TRANSFORMS, 0);
}
void qbist(s_info info, gchar *buffer, int xp, int yp, int num, int width, int height, int bpp)
{
gushort gx;
......@@ -127,14 +173,16 @@ void qbist(s_info info, gchar *buffer, int xp, int yp, int num, int width, int h
for(gx=0; gx<num; gx ++) {
for(i=0; i<NUM_REGISTERS; i++) {
reg[i][0] = ((float)gx+xp) / ((float)(width));
reg[i][1] = ((float)yp) / ((float)(height));
reg[i][2] = ((float)i) / ((float)NUM_REGISTERS);
if (used_reg_flag[i]) {
reg[i][0] = ((float)gx+xp) / ((float)(width));
reg[i][1] = ((float)yp) / ((float)(height));
reg[i][2] = ((float)i) / ((float)NUM_REGISTERS);
}
}
for(i=0;i<MAX_TRANSFORMS; i++) {
sr=info.source[i];cr=info.control[i];dr=info.dest[i];
switch (info.transformSequence[i]) {
if (used_trans_flag[i]) switch (info.transformSequence[i]) {
case PROJECTION: {
gfloat scalarProd;
scalarProd = (reg[sr][0]*reg[cr][0])+(reg[sr][1]*reg[cr][1])+(reg[sr][2]*reg[cr][2]);
......@@ -230,14 +278,14 @@ GParamDef *return_vals = NULL;
int nargs = sizeof(args) / sizeof(args[0]);
int nreturn_vals = 0;
MAIN();
MAIN()
void query(void)
{
gimp_install_procedure(PLUG_IN_NAME,
"Create images based on a random genetic formula",
"This Plug-in is based on an article by "
"Jrn Loviscach. It generates modern art "
"Jrn Loviscach (appeared in c't 10/95, page 326). It generates modern art "
"pictures from a random genetic formula.",
"Jrn Loviscach, Jens Ch. Restemeier",
"Jrn Loviscach, Jens Ch. Restemeier",
......@@ -322,6 +370,8 @@ void run(char *name, int nparams, GParam *param, int *nreturn_vals, GParam **ret
gimp_pixel_rgn_init (&imagePR, drawable, 0,0, img_width, img_height, TRUE, TRUE);
row_data=(guchar *)malloc((sel_x2-sel_x1)*img_bpp);
optimize(qbist_info);
gimp_progress_init ("Qbist ...");
for (row=sel_y1; row<sel_y2; row++) {
qbist(qbist_info, row_data, 0, row, sel_x2-sel_x1, sel_x2-sel_x1, sel_y2-sel_y1, img_bpp);
......@@ -378,6 +428,7 @@ void dialog_update_previews(GtkWidget *widget, gpointer data)
int i, j;
guchar buf[PREVIEW_SIZE * 3];
for (j=0;j<9;j++) {
optimize(info[(j+5) % 9]);
for (i = 0; i < PREVIEW_SIZE; i++) {
qbist(info[(j+5) % 9], buf, 0, i, PREVIEW_SIZE, PREVIEW_SIZE, PREVIEW_SIZE, 3);
gtk_preview_draw_row (GTK_PREVIEW (preview[j]), buf, 0, i, PREVIEW_SIZE);
......@@ -415,23 +466,22 @@ int load_data(char *name)
return(1);
}
void save_data(char *name, int k)
void save_data(char *name)
{
int i=0;
FILE *f;
f=fopen(name, "wb");
for(i=0;i<MAX_TRANSFORMS;i++) PUTMACUSHORT(info[k].transformSequence[i], f);
for(i=0;i<MAX_TRANSFORMS;i++) PUTMACUSHORT(info[k].source[i], f);
for(i=0;i<MAX_TRANSFORMS;i++) PUTMACUSHORT(info[k].control[i], f);
for(i=0;i<MAX_TRANSFORMS;i++) PUTMACUSHORT(info[k].dest[i], f);
for(i=0;i<MAX_TRANSFORMS;i++) PUTMACUSHORT(info[0].transformSequence[i], f);
for(i=0;i<MAX_TRANSFORMS;i++) PUTMACUSHORT(info[0].source[i], f);
for(i=0;i<MAX_TRANSFORMS;i++) PUTMACUSHORT(info[0].control[i], f);
for(i=0;i<MAX_TRANSFORMS;i++) PUTMACUSHORT(info[0].dest[i], f);
fclose(f);
}
void file_selection_save(GtkWidget *widget, GtkWidget *file_select)
{
save_data(gtk_file_selection_get_filename (GTK_FILE_SELECTION(file_select)),
0 /* the middle button */ );
save_data(gtk_file_selection_get_filename (GTK_FILE_SELECTION(file_select)));
gtk_widget_destroy(file_select);
}
......@@ -507,7 +557,7 @@ int dialog_create()
gtk_widget_set_default_colormap (gtk_preview_get_cmap ());
dialog=gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW(dialog), "G-Qbist 1.0");
gtk_window_set_title (GTK_WINDOW(dialog), "G-Qbist 1.10");
gtk_signal_connect (GTK_OBJECT (dialog), "destroy",
(GtkSignalFunc) dialog_close,
NULL);
......@@ -516,7 +566,7 @@ int dialog_create()
gtk_table_set_row_spacings(GTK_TABLE(table), 5);
gtk_table_set_col_spacings(GTK_TABLE(table), 5);
gtk_container_border_width (GTK_CONTAINER (table), 5);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table, TRUE, TRUE, 0);
gtk_widget_show(table);
memcpy((char *)&(info[0]), (char *)&qbist_info, sizeof(s_info));
......
......@@ -193,14 +193,19 @@ save_image (char *filename,
{
int row,col, cols, rows, x, y;
int colcount, colspan, rowspan;
int palloc[drawable->width][drawable->height];
/* This works only in gcc - not allowed according */
/* to ANSI C */
/*int palloc[drawable->width][drawable->height];*/
int *palloc;
guchar *buffer, *buf2;
guchar *width, *height;
GPixelRgn pixel_rgn;
char *name;
FILE *fp, *fopen();
palloc = malloc(drawable->width * drawable->height * sizeof(int));
fp = fopen(filename, "w");
if (gtmvals.fulldoc) {
fprintf (fp,"<HTML>\n<HEAD><TITLE>%s</TITLE></HEAD>\n<BODY>\n",filename);
......@@ -239,7 +244,7 @@ save_image (char *filename,
for (row=0; row < rows; row++)
for (col=0; col < cols; col++)
palloc[col][row]=1;
palloc[drawable->width * row + col]=1;
colspan=0;
rowspan=0;
......@@ -259,8 +264,8 @@ save_image (char *filename,
rowspan=0;
gimp_pixel_rgn_get_pixel(&pixel_rgn, buf2, col, row);
while (color_comp(buffer,buf2) && palloc[col][row] == 1 && row < drawable->height) {
while (color_comp(buffer,buf2) && palloc[col][row] == 1 && col < drawable->width ) {
while (color_comp(buffer,buf2) && palloc[drawable->width * row + col] == 1 && row < drawable->height) {
while (color_comp(buffer,buf2) && palloc[drawable->width * row + col] == 1 && col < drawable->width ) {
colcount++;
col++;
gimp_pixel_rgn_get_pixel(&pixel_rgn, buf2, col, row);
......@@ -282,18 +287,18 @@ save_image (char *filename,
if (colspan > 1 || rowspan > 1) {
for (row=0; row < rowspan; row++)
for (col=0; col < colspan; col++)
palloc[col+x][row+y]=0;
palloc[x][y]=2;
palloc[drawable->width * (row+y) + (col+x)]=0;
palloc[drawable->width * y + x]=2;
}
}
if (palloc[x][y]==1)
if (palloc[drawable->width * y + x]==1)
fprintf (fp," <TD%s%sBGCOLOR=#%02x%02x%02x>",width,height,buffer[0],buffer[1],buffer[2]);
if (palloc[x][y]==2)
if (palloc[drawable->width * y + x]==2)
fprintf (fp," <TD ROWSPAN=\"%d\" COLSPAN=\"%d\"%s%sBGCOLOR=#%02x%02x%02x>",rowspan,colspan,width,height,buffer[0],buffer[1],buffer[2]);
if (palloc[x][y]!=0) {
if (palloc[drawable->width * y + x]!=0) {
if (gtmvals.tdcomp)
fprintf (fp,"%s</TD>\n",gtmvals.cellcontent);
else
......@@ -312,6 +317,8 @@ save_image (char *filename,
free(width);
free(height);
free(palloc);
return 1;
}
......
/* maze.c, version 0.5.0, July 10, 1998.
/* maze.c, version 0.6.2, March 7, 1998.
* This is a plug-in for the GIMP.
* It draws mazes...
*
......@@ -19,6 +19,11 @@
* and used as a template to get me started on this one. :)
*
* Revision history:
* 0.6.2 - drawbox rewritten with memcpy and a row buffer. By the way, Maze is now
* faster than Checkerboard.
* - Added Help button using extension_web_browser.
* - Added DIVBOX_LOOKS_LIKE_SPINBUTTON flag. Doesn't look too hot, set to
* FALSE by default.
* 0.6.1 - Made use-time-for-random-seed a toggle button that remembers
* its state, and moved seed to the second notebook page.
* 0.6.0 - Width and height are now seperate options.
......@@ -50,6 +55,8 @@
* 0.1.0 - First release. It works! :)
*
* TO DO:
* Rework the divboxes to be more like spinbuttons.
*
* Add an option to kill the outer border.
*
* Fix that stray line down there between maze wall and dead space border...
......@@ -380,37 +387,99 @@ maze( GDrawable * drawable)
gimp_drawable_update (drawable->id, x1, y1, (x2 - x1), (y2 - y1));
}
/* Draws a solid color box in a GPixelRgn. */
/* Optimization assumptions:
* (Or, "Why Maze is Faster Than Checkerboard.")
*
* Assuming calling memcpy is faster than using loops.
* Row buffers are nice...
*
* Assume allocating memory for row buffers takes a significant amount
* of time. Assume drawbox will be called many times.
* Only allocate memory once.
*
* Do not assume the row buffer will always be the same size. Allow
* for reallocating to make it bigger if needed. However, I don't see
* reason to bother ever shrinking it again.
* (Under further investigation, assuming the row buffer never grows
* may be a safe assumption in this case.)
*
* Also assume that the program calling drawbox is short-lived, so
* memory leaks aren't of particular concern-- the memory allocated to
* the row buffer is never set free.