55 Commits

Author SHA1 Message Date
David Capello
ec42689b82 Avoid setting an invalid mask color (-1) in doc::Image (fix #4651)
This regression came from 09bb5cc3d3676e88048d5cd845b075ea30ca8e66 as
now we don't Sprite::setTransparentColor() on each undo/redo and only
when needed. This brought a new kind of error where the mask color for
images was set to -1 after convert_pixel_format().

This also fixes a conversion from Indexed -> RGB where the transparent
color was not set back to 0. And the transparent color is always set
when we are in indexed mode to avoid any assert in debug mode.
2024-09-11 12:35:21 -03:00
David Capello
1f71286960 Minor change in convert_pixel_format() using "auto" keyword 2022-11-03 19:43:31 -03:00
Gaspar Capello
2785a9fef7 Remove fillOrphansNodes(), now new colors are added to the octree color arragement
This gives more accuracy in the color picking criteria on new images
pasted into an INDEXED sprite.

Also, added findMaskColor to fix the behavior reported in #3207

Both issues are related when RGBMAP is created. The 'mask color' and
'mask index' must be defined correctly to include/exclude during the
table/octree map color search.

To do: Converting sprite to INDEXED should add 'mask color' to the
palette when color count < 256 and transparent color isn't in the
palette.
2022-07-14 14:27:20 -03:00
David Capello
91c687b1e3 Merge branch 'main' into beta 2021-12-15 17:51:19 -03:00
Joshua Ogunyinka
f567805591 Fix allowing alpha channel if layer is converted from indexed image (fix #3073) 2021-12-15 15:03:57 -03:00
David Capello
5238bfc7d7 Merge branch 'main' into beta (fix #2970) 2021-09-29 14:54:30 -03:00
David Capello
d7ddb7feed Fix changing random values to transparent color for non-indexed sprite from cmd::SetPalette
Possible fix for #2970
Possible regression introduced in dd2d226264b0960145a7e04a97a4aa3669330ad3
2021-09-29 14:42:55 -03:00
Gaspar Capello
5f48d77786 Add octree quantization algorithm supports alpha channel
Before this commit, Octree wasn't support alpha channel.
Also the automatic quantization algorithm selection was removed because Octree support alpha channel now.
2021-06-04 10:06:06 -03:00
David Capello
69a7faefa2 New default RgbMapAlgorithm to select what could works better at a given time 2021-05-09 20:53:09 -03:00
David Capello
4e896b8a65 Merge branch 'fix-gif' into beta 2020-06-17 23:52:49 -03:00
David Capello
bcf53fa54a Merge branch 'octree' into beta 2020-06-17 23:33:41 -03:00
David Capello
1f34d0e46e Add different formulas to convert RGB to Grayscale 2020-04-20 10:22:41 -03:00
Gaspar Capello
696bb9a537 Add possibility to use OctreeMap in create_palette_from_image() 2020-04-14 20:01:25 -03:00
David Capello
ad31c9b7a8 Convert RgbMap into an interface and rename the old class to RgbMapRGB53A 2020-04-10 10:15:04 -03:00
David Capello
b007c4dd0e Minor changes/comments to new gif encoder 2020-04-09 10:24:24 -03:00
Gaspar Capello
7ed83c10cc Fix gif format encoding 2020-04-09 10:23:36 -03:00
David Capello
b628e21e76 Replace MIN/MAX() macros with std::min/max() functions 2020-04-08 12:20:53 -03:00
David Capello
2a42cc1bf6 Quantization: Generate 1st pal entry w/alpha=0 for mask color on transparent layers when possible (fix #2109) 2019-08-12 16:43:36 -03:00
David Capello
109e6fa205 Add render::Dithering() class to store all dithering parameters 2019-04-03 19:32:24 -03:00
David Capello
fcf272bb69 Add amount parameter to Error Diffusion algorithm 2019-04-03 18:45:18 -03:00
David Capello
20b8ee0e57 Add Floyd-Steinberg dithering for RGBA -> Indexed conversion 2019-04-01 22:00:32 -03:00
Gaspar Capello
f53544842c Fix non-normal blend modes when the backdrop is transparent (fix #1096) 2019-03-09 12:40:31 -03:00
David Capello
f2ed45e795 Replace base::UniquePtr -> std::unique_ptr 2018-08-08 17:27:26 -03:00
David Capello
245285f84e Filters: Use the selected cels range instead of target buttons
With this commit we've definitely removed the target buttons to apply a
filter in current cel/layer/frame (which never make too much sense to
the end-user), and now we can just select the range of
layers/frames/cels where we want to apply the filter (like Flip and
Rotate commands that were already working in this way).
2018-03-13 17:05:14 -03:00
David Capello
4fc19c5466 Change "old-ordered" dithering algorithm to just "old" 2017-05-23 14:56:06 -03:00
David Capello
bcdf598392 Add widget to choose dithering algorithm + matrix 2017-05-22 15:44:08 -03:00
David Capello
5ef6aac925 Add --dithering-matrix CLI option
Now the dithering matrix used in ordered dithering algorithm is configurable.
2017-05-19 15:49:31 -03:00
David Capello
03276e0264 Fix ordered dithering issues converting transparent layers + alpha palette entries 2017-05-19 10:17:22 -03:00
David Capello
573cad4777 Add progress bar to color conversion
Unified render tasks stop/progress notifications in render::TaskDelegate
interface.
2017-05-17 15:25:40 -03:00
David Capello
16aeae0833 Add new ordered dithering algorithm 2017-05-17 13:32:34 -03:00
David Capello
cbee0862f3 Add a Color Mode conversion dialog with preview 2017-05-16 17:18:55 -03:00
David Capello
23272895c4 Move doc::DitheringMethod -> render::DitheringAlgorithm 2017-05-15 16:26:44 -03:00
David Capello
f4b9f3c322 Use Sprite::allLayersCount/allLayers() when possible 2016-08-11 21:28:45 -03:00
David Capello
5f97e66a8b Include base/base.h on files that use MIN/MID/MAX 2016-03-03 19:18:46 -03:00
David Capello
3c219571b1 Don't change mask-index entry if it's out of the bound in PaletteOptimizer::calculate() 2015-09-24 23:39:36 -03:00
David Capello
ffba179712 Avoid an extra palette entry for the mask color in PaletteOptimizer::calculate() (fix #771) 2015-08-24 19:05:36 -03:00
David Capello
0d5ba77ba4 Add support to create palettes for Indexed images (fix #751) 2015-08-20 12:37:58 -03:00
David Capello
b35fc87ec1 Add progress bar when a palette is created from a RGB file 2015-07-22 18:26:25 -03:00
David Capello
7f4d4936e1 Re-implement GIF encoder
- Correct usage of disposal methods (and possibility to generate records
  with "restore previous frame" disposal method)
- Create color maps for each frame when necessary
- Remove options to dither RGB images (to simplify encoder)
2015-07-22 16:40:44 -03:00
David Capello
91988de955 Remove unused function create_palette_from_images() 2015-07-22 14:31:59 -03:00
David Capello
b426171679 Add new_mask_color parameter to convert_pixel_format() function
When we converted an Indexed image to RGB, the original sprite
transparent color was being kept but the mask color of all its images
was reset to 0. With this change we kept the same mask color on all images
to avoid an assert() in the render code.

Anyway the whole RGB <-> Indexed conversion should be reviewed in these
cases. I think there are some situation where a transparent color = 0 is
expected in RGB sprites (as we shouldn't be able to change the transparent
color of an RGB sprite).
2015-07-14 09:44:31 -03:00
David Capello
e9308c2d35 Add alpha channel in quantization (related to #286) 2015-07-02 11:18:43 -03:00
David Capello
372d604d93 Add support for alpha channel in RgbMap and Palette::findBestfit()
This include several changes:
- Color::getIndex() can return palette values with alpha != 255
- Fix Transparent and Blurs ink for indexed images to make better use
  of palette entries with alpha values
- Fix bilinear resize algorithm for indexed images with alpha
- New RgbMap with four parameters: R, G, B, A
- Add one extra color scale function used in the alpha channel of the
  new RgbMap
- Fix color curve, convolution matrix, invert color, and median filters
  to take care of this new alpha channel on indexed images
- Fix ordered dithering and quantization

Related to #286
2015-07-01 21:33:30 -03:00
David Capello
8f24c05451 Fix indexed -> RGB/grayscale conversion when palette colors have alpha 2015-06-30 21:25:27 -03:00
David Capello
70ea54aa20 Re-implement ordered dither in render library 2015-06-22 20:58:33 -03:00
David Capello
ae0bf75965 Fix creation of optimized palettes from RGB images
It's working again, now we create palettes with 256 colors (or less)
for RGB images.
2015-06-22 19:40:28 -03:00
David Capello
89e0392daa Add support for palettes with more less (and more) than 256 colors (fix #668)
With this commit we've removed doc::Palette::MaxColors constant.
2015-06-18 12:50:33 -03:00
David Capello
21ca87862c Add layer blending modes (fix #318)
- Added doc::BlendMode enum and doc::BlendFunc type
- Renamed LayerImage::getBlendMode() -> blendMode()
- BLEND_MODE_COPY is BlendMode::SRC now
- BLEND_MODE_NORMAL is BlendMode::NORMAL now
- Added app::cmd::SetLayerBlendMode
2015-06-13 21:29:16 -03:00
David Capello
9a6ac48bfa Fix circular dependencies between image_impl.h <-> image_iterator.h
This problem was introduced in d732f5b05f33ed1fce4c8b900a54f617bfb4c5ae

Now image_iterator.h and image_bits.h use forward declarations. And if
someone want to use the Image implementation, ImageBits, LockImageBits,
ImageIterators, or some function inside primitive_fast.h, they just have
to include image_impl.h file.
2015-06-12 13:56:18 -03:00
David Capello
85d638097b Use rendered images to create optimized palette in render::create_palette_from_rgb() 2015-05-21 10:17:59 -03:00