Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Version 3.44.92
Added RGBA compositing of layers - background now can use transparency just like any layer
Moved keyboard shortcuts into V-code and added key remapping dialog
Moved all ACTMAP functionality into V-code
Changes to V-code engine to support all of the above
Large rewrite of inifile engine, to make it more usable for key mapping
Some more changes to support tool scripting in future
Added detection of switched palette order when saving files as black and white
Fixed bug that produced broken files when writing composite images as PMM
  • Loading branch information
wjaguar committed Apr 26, 2015
1 parent 15ec7b6 commit 44520cc
Show file tree
Hide file tree
Showing 20 changed files with 1,649 additions and 655 deletions.
10 changes: 7 additions & 3 deletions NEWS
Expand Up @@ -4,17 +4,20 @@ mtPaint NEWS

Here is a summary of the main changes in this release (see handbook for full details):

3.45 2015-??-??
3.50 2015-??-??
* Scripting added - "Image->Script" to enter or run a script : See handbook section A.9 for details
* Commandline mode added - use "mtpaint --cmd" to run a script without GUI
* Lasso tool can be configured to shrink selection based on the selection channel - right click the tool icon
* Keyboard shortcuts can now be reconfigured - "Help->Keyboard shortcuts"
* New keyboard shortcut Ctrl+H added for Channels->Hide image
* Composite images now can have alpha transparency, when background is non-opaque
* Background layer now can use transparency like any other layer
* Background layer position now can be changed via Ctrl+arrows or layers window spinbuttons, like any other layer
* Lasso tool can be configured to shrink selection based on the selection channel - right click the tool icon
* Ctrl+Right click now deletes last point when making polygonal selection (from a closed polygon, deletes the point nearest to cursor)
* Shift and Shift+Ctrl now constrain selection box width/height when resizing it by clicking and dragging
* Zooming now can use mouse cursor position as its fixed point (Preferences->Interface->Zoom on cursor position)
* Scroll wheel zoom now works for view window too
* "Hide image" and "View alpha as an overlay" can now be toggled separately for each layer (Preferences->General->Enable overlays by layer)
* New keyboard shortcut Ctrl+H added for Channels->Hide image
* New image format PMM (Portable MultiMap) added for interoperable storage and exchange of images : See handbook section A.2 for details
* XPM files with 65-92 colours are now saved with smaller size
* Raw RGB palette files (6-bit PAL and 8-bit ACT) can now be loaded/saved via the Palette menu
Expand All @@ -35,6 +38,7 @@ Here is a summary of the main changes in this release (see handbook for full det
* BUGFIX - New image creation from system clipboard now respects "Undoable" toggle
* BUGFIX - Problem with layers list in inactive dock tab sometimes not updating is now eliminated
* BUGFIX - All keyboard shortcuts now work in Image View mode, as they should
* BUGFIX - Transparent colour in composite images now works again
* BUGFIX - PAM files with type BLACKANDWHITE are no longer loaded as grayscale (except if written as grayscale - ImageMagick does that)
* BUGFIX - Animation cycling now doesn't skip over the last frame of a GIF loaded into layers
* BUGFIX - Background layer is now made large enough to accommodate all frames when loading animation into layers
Expand Down
4 changes: 2 additions & 2 deletions configure
Expand Up @@ -4,8 +4,8 @@

echo

MT_V="3.44.91"
MT_DATE="2015-04-05"
MT_V="3.44.92"
MT_DATE="2015-04-26"

MT_VERSION="mtPaint $MT_V"
MT_LANG=NO
Expand Down
29 changes: 13 additions & 16 deletions src/ani.c
Expand Up @@ -698,7 +698,7 @@ static void create_frames_ani()
image_info *image;
ls_settings settings;
png_color pngpal[256], *trans;
unsigned char *layer_rgb, *irgb = NULL;
unsigned char *layer_rgb, *irgb;
char output_path[PATHBUF], *command, *wild_path;
int a, b, k, i, tr, cols, layer_w, layer_h, npt, l = 0;

Expand All @@ -720,7 +720,7 @@ static void create_frames_ani()
if ( errno != EEXIST )
{
alert_box(_("Error"), _("Unable to create output directory"), NULL);
goto failure; // Failure to create directory
return; // Failure to create directory
}
}

Expand All @@ -733,13 +733,13 @@ static void create_frames_ani()

layer_w = image->width;
layer_h = image->height;
layer_rgb = malloc( layer_w * layer_h * 3); // Primary layer image for RGB version

layer_rgb = malloc(layer_w * layer_h * 4); // Primary layer image for RGB version
if (!layer_rgb)
{
memory_errors(1);
goto failure;
return;
}
irgb = layer_rgb + layer_w * layer_h * 3; // For indexed or alpha

/* Prepare settings */
init_ls_settings(&settings, NULL);
Expand All @@ -750,22 +750,17 @@ static void create_frames_ani()
settings.silent = TRUE;
if (ani_use_gif)
{
irgb = malloc(layer_w * layer_h); // Resulting indexed image
if (!irgb)
{
free(layer_rgb);
memory_errors(1);
goto failure;
}
settings.ftype = FT_GIF;
settings.img[CHN_IMAGE] = irgb;
settings.bpp = 1;
settings.pal = pngpal;
}
else
{
if (!comp_need_alpha(FT_PNG)) irgb = NULL;
settings.ftype = FT_PNG;
settings.img[CHN_IMAGE] = layer_rgb;
settings.img[CHN_ALPHA] = irgb;
settings.bpp = 3;
/* Background transparency */
settings.xpm_trans = tr = image->trans;
Expand All @@ -779,7 +774,7 @@ static void create_frames_ani()
break;

ani_set_frame_state(k); // Change layer positions
memset(layer_rgb, 0, layer_w * layer_h * 3); // In case background has holes
memset(layer_rgb, 0, layer_w * layer_h * 4); // Init for RGBA compositing
view_render_rgb( layer_rgb, 0, 0, layer_w, layer_h, 1 ); // Render layer

snprintf(output_path + l, PATHBUF - l, DIR_SEP_STR "%s%05d.%s",
Expand Down Expand Up @@ -817,6 +812,11 @@ static void create_frames_ani()
}
}
}
else if (irgb)
{
collect_alpha(irgb, layer_w, layer_h);
mem_demultiply(layer_rgb, irgb, layer_w * layer_h, 3);
}

if (save_image(output_path, &settings) < 0)
{
Expand All @@ -840,9 +840,6 @@ static void create_frames_ani()
failure2:
progress_end();
free( layer_rgb );

failure:
free( irgb );
}

void pressed_remove_key_frames()
Expand Down
32 changes: 22 additions & 10 deletions src/canvas.c
Expand Up @@ -1162,7 +1162,7 @@ void update_menus() // Update edit/undo menu
}
if (j > 1) statemap |= NEED_CHAN;

mapped_item_state(statemap);
cmd_setv(main_window_, (void *)statemap, WDATA_ACTMAP);

/* Switch to default tool if active smudge tool got disabled */
if ((tool_type == TOOL_SMUDGE) &&
Expand Down Expand Up @@ -1608,6 +1608,8 @@ int ftype_selector(int mask, char *ext, int def, char **names, int *ftypes)

void init_ls_settings(ls_settings *settings, void **wdata)
{
png_color *pal = mem_pal;

/* Set defaults */
memset(settings, 0, sizeof(ls_settings));
settings->ftype = FT_NONE;
Expand Down Expand Up @@ -1643,11 +1645,14 @@ void init_ls_settings(ls_settings *settings, void **wdata)
#ifdef U_LCMS
apply_icc = dt->icc;
#endif
// Use background's palette
if ((dt->mode == FS_COMPOSITE_SAVE) && layer_selected)
pal = layer_table[0].image->image_.pal;
}

/* Default expansion of xpm_trans */
settings->rgb_trans = settings->xpm_trans < 0 ? -1 :
PNG_2_INT(mem_pal[settings->xpm_trans]);
PNG_2_INT(pal[settings->xpm_trans]);
}

static void store_ls_settings(ls_settings *settings)
Expand All @@ -1657,10 +1662,11 @@ static void store_ls_settings(ls_settings *settings)
switch (settings->mode)
{
case FS_PNG_SAVE:
case FS_CHANNEL_SAVE:
case FS_COMPOSITE_SAVE:
if (fflags & FF_TRANS)
mem_set_trans(settings->xpm_trans);
// Fallthrough
case FS_CHANNEL_SAVE:
case FS_COMPOSITE_SAVE:
if (fflags & FF_SPOT)
{
mem_xbm_hot_x = settings->hot_x;
Expand Down Expand Up @@ -1941,6 +1947,9 @@ void file_selector_x(int action_type, void **xdata)
memset(&tdata, 0, sizeof(tdata));
tdata.mode = action_type;
tdata.fpmode = FPICK_ENTRY;
tdata.xtrans[0] = mem_xpm_trans;
tdata.xtrans[1] = -1;
tdata.xtrans[2] = mem_cols - 1;
switch (action_type)
{
case FS_PNG_LOAD:
Expand Down Expand Up @@ -2026,6 +2035,12 @@ void file_selector_x(int action_type, void **xdata)
tdata.fmask = FF_RGB;
tdata.title = _("Save Composite Image");
tdata.need_save = TRUE;
if (layer_selected) // Use background's transparency
{
image_info *image = &layer_table[0].image->image_;
tdata.xtrans[0] = image->trans;
tdata.xtrans[2] = image->cols - 1;
}
break;
case FS_CLIP_FILE:
case FS_SELECT_FILE:
Expand Down Expand Up @@ -2062,9 +2077,6 @@ void file_selector_x(int action_type, void **xdata)
tdata.ftnames = names;
}

tdata.xtrans[0] = mem_xpm_trans;
tdata.xtrans[1] = -1;
tdata.xtrans[2] = mem_cols - 1;
tdata.xx[0] = mem_xbm_hot_x;
tdata.xx[1] = -1;
tdata.xx[2] = mem_width - 1;
Expand Down Expand Up @@ -2180,7 +2192,7 @@ static void rec_continuous(int nx, int ny, int w, int h)

/* Redraw starting square only if need to fill in possible gap when
* size changes, or to draw stroke gradient in the proper direction */
if (!tablet_working && !STROKE_GRADIENT)
if (!tablet_working && !STROKE_GRADIENT && !script_cmds)
{
i2 = tool_ox + dx[i + 1] + 1 - i * 2;
j2 = tool_oy + dy[j + 1] + 1 - j * 2;
Expand Down Expand Up @@ -2520,7 +2532,7 @@ void tool_action(int count, int x, int y, int button, int pressure)
}
else if ( tool_ox == x && tool_oy == y ) return; // Only do something with a new point

if ( tablet_working )
if (tablet_working || script_cmds)
{
// !!! Later maybe switch the calculations to integer
double p = pressure <= (MAX_PRESSURE * 2 / 10) ? -1.0 :
Expand Down Expand Up @@ -2844,7 +2856,7 @@ void tool_action(int count, int x, int y, int button, int pressure)
tool_ox = x; // Remember the coords just used as they are needed in continuous mode
tool_oy = y;

if (tablet_working) tool_state = o_tool;
if (tablet_working || script_cmds) tool_state = o_tool;
}

void check_marquee() // Check marquee boundaries are OK - may be outside limits via arrow keys
Expand Down
2 changes: 1 addition & 1 deletion src/font.c
Expand Up @@ -735,7 +735,7 @@ static void font_index_load(char *filename)


font_mem = wjmemnew(0, 0);
font_text = slurp_file(filename);
font_text = slurp_file(filename, 1);
if (!font_mem || !font_text)
{
font_mem_clear();
Expand Down

0 comments on commit 44520cc

Please sign in to comment.