Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
_conf.txt
.vscode
src/graphics
*.mo
*.o
src/mtpaint
.vstags
.project
.cproject

9 changes: 6 additions & 3 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

echo

MT_V="3.49.13"
MT_DATE="2017-10-20"
MT_V="3.49.14"
MT_DATE="2018-08-07"

MT_VERSION="mtPaint $MT_V"
MT_LANG=NO
Expand Down Expand Up @@ -71,6 +71,7 @@ do
"notiff" ) NTIFF=NO;;
"statictiff" ) STATIC_TIFF=TIFF;;
"noft" ) NFT=NO;;
"legacyft" ) LEGACYFT=NO;;
"staticft" ) STATIC_FT=FreeType;;
"lcms" ) NCMS=LittleCMS;;
"lcms2" ) NCMS=LittleCMS2;;
Expand Down Expand Up @@ -197,6 +198,7 @@ tiff ............. Use libtiff
notiff ........... Don't use libtiff
statictiff ....... Statically link TIFF library
noft ............. Don't use FreeType
legacyft ......... Use non-pkg-config freetype search on Linux
staticft ......... Statically link FreeType library
lcms ............. Use LittleCMS
lcms2............. Use LittleCMS2
Expand Down Expand Up @@ -444,6 +446,7 @@ NTIFF=${NTIFF:-NO}

if IS_LIB "lfreetype"
then
LEGACYFT=${LEGACYFT:-no}
NFT=${NFT:-YES}
fi
NFT=${NFT:-NO}
Expand Down Expand Up @@ -577,7 +580,7 @@ fi
if [ "$NFT" = YES ]
then
DEFS="$DEFS -DU_FREETYPE"
if [ "$OS" = "GNU/Linux" ]
if [ "$OS" = "GNU/Linux" ] && [ "$LEGACYFT" = "YES" ]
then # Do it the old way, for native builds on *very* old distros
INCLUDES="$INCLUDES `freetype-config --cflags`"
LIB_NAME "" "$STATIC_FT" "`freetype-config --libs`"
Expand Down
32 changes: 32 additions & 0 deletions src/canvas.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,38 @@ void pressed_kuwahara()
run_create_(filterwindow_code, &tdata, sizeof(tdata), script_cmds);
}

typedef struct {
filterwindow_dd fw;
int noise_type;
} noise_dd;

static char *noise_txt[] = { _("Colored"), _("A to B"), _("A or B"), NULL};

static int do_noise(noise_dd *dt, void **wdata)
{
run_query(wdata);
spot_undo(UNDO_DRAW);
mem_noise(dt->noise_type);
mem_undo_prepare();
return (TRUE);
}

#define WBbase noise_dd
static void *noise_code[] = {
VBOXPS,
FRPACK(_("Noise type"), noise_txt, NOISE_MAX, 1, noise_type),
WDONE, RET
};
#undef WBbase

void pressed_noise()
{
noise_dd tdata = {
{ _("Noise"), noise_code, FW_FN(do_noise) },
NOISE_COLOR };
run_create_(filterwindow_code, &tdata, sizeof(tdata), script_cmds);
}

void pressed_convert_rgb()
{
unsigned char *old_img = mem_img[CHN_IMAGE];
Expand Down
1 change: 1 addition & 0 deletions src/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ void pressed_gauss();
void pressed_unsharp();
void pressed_dog();
void pressed_kuwahara();
void pressed_noise();

void pressed_clip_alpha_scale();
void pressed_clip_alphamask();
Expand Down
5 changes: 5 additions & 0 deletions src/mainwindow.c
Original file line number Diff line number Diff line change
Expand Up @@ -4767,6 +4767,8 @@ void action_dispatch(int action, int mode, int state, int kbd)
pressed_unassociate(); break;
case FILT_KUWAHARA:
pressed_kuwahara(); break;
case FILT_NOISE:
pressed_noise(); break;
}
}

Expand Down Expand Up @@ -5364,6 +5366,9 @@ static void *main_menu_code[] = {
MENUITEMs(_("//Erode"), ACTMOD(FILT_FX, FX_ERODE)),
ACTMAP(NEED_NOIDX),
MENUSEP, //
MENUITEMs(_("//Noise ..."), ACTMOD(FILT_NOISE, 0)),
ACTMAP(NEED_NOIDX),
MENUSEP, //
MENUITEMs(_("//Bacteria ..."), ACTMOD(FILT_BACT, 0)),
ACTMAP(NEED_IDX),
WDONE,
Expand Down
1 change: 1 addition & 0 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ enum { // To let constants renumber themselves when adding new ones
FILT_THRES,
FILT_UALPHA,
FILT_KUWAHARA,
FILT_NOISE,

ACT_TEST /* Reserved for testing things */
};
Expand Down
72 changes: 72 additions & 0 deletions src/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -8156,6 +8156,78 @@ void mask_merge(unsigned char *old, int channel, unsigned char *mask)
}
}

/* Noise filter */
void mem_noise(int type) {
int i, j;
unsigned char *img;

unsigned char *mask = calloc(1, mem_width);

j = mem_width * mem_height;
if (mem_channel == CHN_IMAGE) j *= 3;
img = mem_img[mem_channel];

switch(type) {
case NOISE_COLOR:
for (i = 0; i < j; i++)
{
*img++ = rand();
}
break;
case NOISE_AORB:
if (mem_channel == CHN_IMAGE)
{
for (i = 0; i < j; i += 3)
{
png_color next = rand() % 2 ? mem_col_A24 : mem_col_B24;
*img++ = next.red;
*img++ = next.green;
*img++ = next.blue;
}
}
else
{
for (i = 0; i < j; i++)
{
unsigned char next = rand() % 2 ? channel_col_A[mem_channel] : channel_col_B[mem_channel];
*img++ = next;
}
}
break;
case NOISE_ATOB:
if (mem_channel == CHN_IMAGE)
{
png_color col1 = mem_col_A24;
png_color col2 = mem_col_B24;
for (i = 0; i < j; i += 3)
{

float rnd = (float) rand() / RAND_MAX;
*img++ = col1.red + round((col2.red - col1.red) * rnd);
*img++ = col1.green + round((col2.green - col1.green) * rnd);
*img++ = col1.blue + round((col2.blue - col1.blue) * rnd);
}
}
else
{
char col1 = channel_col_A[mem_channel];
char col2 = channel_col_B[mem_channel];
for (i = 0; i < j; i++)
{
float rnd = (float) rand() / RAND_MAX;
*img++ = col1 + round((col2 - col1) * rnd);
}
}
break;

}
if (mask)
{
mask_merge(mem_undo_previous(mem_channel), mem_channel, mask);
free(mask);
}
}

static void dog_filter(tcb *thread)
{
gaussd *gd = thread->data;
Expand Down
9 changes: 9 additions & 0 deletions src/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,15 @@ void mem_unsharp(double radius, double amount, int threshold, int gcor);
void mem_dog(double radiusW, double radiusN, int norm, int gcor);
void mem_kuwahara(int r, int gcor, int detail);

static enum {
NOISE_COLOR,
NOISE_ATOB,
NOISE_AORB,
NOISE_MAX
};

void mem_noise(int);

/* Colorspaces */
#define CSPACE_RGB 0
#define CSPACE_SRGB 1
Expand Down