Commit Graph

34 Commits

Author SHA1 Message Date
David Capello 7fb8cfc8fa Avoid including image impl details as much as possible (image_impl/bits/iterator.h)
Including doc/image.h should be enough to access/iterate the image
pixels.
2024-12-19 09:44:37 -03:00
David Capello 09538f9a1a clang-format all files 2024-12-16 14:52:19 -03:00
David Capello 8f7bf09263 Fix doc::blend_image() to support different color modes (fix #4530, fix #4531)
The code was refactored moving the BlenderHelper class from "render"
to "doc", and now doc::blend_image() supports blending different color
modes.

Some work is still needed to work with grayscale images correctly.
2024-06-11 21:48:57 -03:00
David Capello dd5fb871b5 Remap tiles with flags correctly 2023-11-10 11:55:23 -03:00
David Capello aeeef8e255 Add suppor for doc::Image row stride size > width size
This patch solves several problems introducing the possibility to
specify a row stride bigger than the width (visible pixels) on each
image row. Useful in case that we want to align the initial pixel
address of each row (if DOC_USE_ALIGNED_PIXELS is defined).

This allows us to use some SIMD intrinsics (e.g. SSE2) for some image
functions in the future (right now implemented only in the new
is_same_image_simd_templ() for is_same_image()).

Anyway to avoid breaking some existing code, by default we'll still
keep the old behavior: row stride bytes = width bytes (so
DOC_USE_ALIGNED_PIXELS is undefined).
2023-08-07 15:27:39 -03:00
Gaspar Capello 637632eafb [lua] Add blend modes to Image:drawImage() 2023-03-27 20:31:58 -03:00
David Capello b83f2953f9 Merge branch 'main' into beta 2021-06-11 16:36:57 -03:00
Gaspar Capello 1eace24891 Improve aspect of ellipses for 16x16 or bigger sizes (fix #2217)
Now algo_ellipse() function supports additional parameters to create
rounded squares in the future.
2021-06-11 14:47:23 -03:00
David Capello 963602444f Merge branch 'main' into beta 2021-05-23 13:16:36 -03:00
David Capello 141bc434bf Fix bug undoing a Remap operation when several colors are removed from the palette 2021-05-20 19:43:18 -03:00
Gaspar Capello b26d3dc7b6 Minor fix in primitives.cpp 2021-05-20 10:53:26 -03:00
David Capello e6bf19e1c1 Fix bug not re-using a tile when A=0 and RGB values are different
When alpha=0, we can ignore RGB values and re-use a tile in the
tileset.
2021-04-19 16:56:30 -03:00
David Capello 80322af02e Use CityHash for tiles
This reduces the level of collisions between hash buckets between
different image tiles.
2021-04-19 15:56:47 -03:00
David Capello c2e5e69882 Simplify tilesets impl using tile index 0 = an empty tile
In this way we always have an empty tile available in the drawing
process. We've also added the Tileset::firstVisibleIndex field to
change the visible index of the tile 1 so we can offset the visible
number by the user (just as a visual aid / simulate old tilesets with
index=0=non-empty tile).
2020-10-30 16:33:34 -03:00
David Capello 50fd450e5e Fix remap of tiles when we delete a tile from the tileset 2020-10-19 16:30:15 -03:00
Gaspar Capello a195487fc0 Fix bounds calculation on tiles drawing outside cel bounds and the filling tile index is tile_i_notile, instead of empty tile. 2020-08-06 10:52:41 -03:00
David Capello 92b794d457 Add the final TilesetModes UI: Manual/Semi/Auto 2020-02-17 09:06:01 -03:00
David Capello 26139c4ae2 Add tilemap layers (#977)
This is the first commit with a simple tilemap editor. Still buggy but
functional in several ways. Several changes were made:

* NewLayer command can receive a tilemap=true to create a new tilemap
  layer
* New ToggleTilesMode command added to switch between the palette and
  the tileset in the ColorBar (the ColorBar was expanded to show
  colors or tilesets with a generic AbstractPaletteViewAdapter)
* All commands to create new layers were moved to Layer >
  New... submenu
* There are a new tileset chunk to save tilesets in .aseprite files,
  and a new kind of cels to save tilemaps
* Added doc::LayerTilemap, doc::Tileset, etc. and several other types
  to handle tilesets/tilemaps in the doc layer.
* Added doc::Grid class with grid specifications that indicates how a
  tilemap <-> tileset must be drawn
* Added and expanded cel operations to work with tilemaps and
  conversions between regular LayerImage cels <-> LayerTilemap cels
  (e.g. copy cels in the timeline between layer types)
2020-02-17 09:06:00 -03:00
David Capello 51be644bf4 Merge duplicated samples when -sheet-pack is used (fix #1316) 2019-10-02 12:55:09 -03:00
David Capello 259733e87d Fix is_empty_image() function using the maskColor in Indexed mode 2018-12-06 11:24:13 -03:00
David Capello 7c2038e7b5 Adjust line algorithm depending on each case (fix #1944, #1894, #1395)
Related to this bug report:
https://community.aseprite.org/t/1045
2018-12-05 22:56:20 -03:00
David Capello dea603753b lua: Add Image:isEqual() 2018-11-13 12:52:51 -03:00
David Capello c657038b1a Support --ignore-empty for --save-as (fix #551) 2018-11-07 16:56:32 -03:00
David Capello b13ac1d340 Add crop_image() with a gfx::Rect 2016-07-01 18:42:10 -03:00
David Capello 2dbb50cc23 Fix exception text in doc::crop_image() 2016-05-05 15:18:50 -03:00
David Capello 210d9c7591 Add warning and correct undo information for unsafe remaps in 8-bit images (fix #715) 2015-07-06 16:15:54 -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 d732f5b05f

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 4d055a7170 Rename gfx::Rect::createIntersect -> createIntersection 2015-06-09 16:22:47 -03:00
David Capello 98cd5056b3 Remove now unused doc::draw_brush() function 2015-04-26 16:29:23 -03:00
David Capello e55865843e Replace undo impl: replace undoers with cmds
Undoers were little objects to swap/revert an action. They didn't
execute the action itself, they just revert its previous state. Now
undoers were replaced with cmds: A cmd is an object that
executes/undoes/redoes just one action.

Changes:
* Remove old undo library and app/objects_container_impl.cpp
  (now we use the doc::ObjectId directly to store undo info)
* Remove all Undoers from app/undoers/
* Replace DocumentApi impl with little Cmds in app/cmd/, these
  cmds handle execute/undo/redo of each action at the logic layer
* Remove doc::Dirty object
* Remove doc::Settings: all undo configuration is in the app side
* Move undo options from app:ISettings to app::Preferences
* Rename UndoTransaction to Transaction
* Create a CmdSequence to store a sequence of Cmds (as now the new
  undo library doesn't support open/close groups)
* Add doc::get<T>(ObjectId) function to get any kind of object
  from the doc library by its ID
* Add Cel::document() and Sprite::document() members
* Add Sprite::cels(frame_t) to get all cels in the given frame
* Add Layer::displaceFrames() member function
* Move the "allow non-linear history" flag from undo2::UndoHistory
  to app::DocumentUndo
2015-01-18 22:05:33 -03:00
David Capello da1358c5dc Unify all render code in one library
Changes:
* Create render library (move util/render.cpp to render/render.cpp)
* Move app::Zoom class to render::Zoom
* Remove doc::Image::merge() member function
* Add gfx::Clip helper class (to clip dst/src rectangles before a blit)
* Move doc::composite_image() to render::composite_image()
* Remove doc::Sprite::render()
* Replace Sprite::getPixel() with render::get_sprite_pixel()
* Remove doc::layer_render() function
* Convert DitheringMethod to a enum class
* Add AppRender to configure a render::Render with the app configuration
* Move checked background preferences as document-specific configuration
* Add doc::Sprite::layer() and palette() member functions
* Add doc::Layer::cel() member function
* Add doc::Palette::entry() member function()
* Add doc::frame_t type
* Move create_palette_from_rgb/convert_pixel_format to render library
* ExportSpriteSheet doesn't need a temporary image now that we can specify
  the source rectangle in the render routine
2014-12-28 11:06:11 -03:00
David Capello afbd3b2d96 Optimize ToolLoop with modified regions of pixels
Here we avoid copying and clearing pixels that will not be used
in the whole tool loop process.
Changes:
* Add several member functions in ToolLoop to validate/invalidate regions
  of source/destination images so we know what regions are safe to use
  by inks and can be shown in the editor
* Add new DocumentObserver::onExposeSpritePixels() member to validate
  pixels that will be displayed in the editor
* Add Ink::needs/createSpecialSourceArea() member functions to validate
  extra areas for inks like blur or jumble
* Add undoers::ModifiedRegion to save the undo information about the
  modified region
* Add ShowHideDrawingCursor class
* Change "blur" tool policy from overlap to accumulate

(This is a real fix for issue #239)
2014-12-08 14:57:56 -03:00
David Capello 63995c6f0a Merge "raster" namespace into "doc" library 2014-10-20 22:21:31 -03:00