Compare commits

...

4 Commits

Author SHA1 Message Date
Gaspar Capello 0b302fdeff
Merge 5afa9e6b82 into 577caa4793 2025-10-01 05:24:48 -03:00
David Capello 577caa4793 Reword action names when dropping files/images onto the timeline
build / build (Debug, macos-latest, lua, cli) (push) Has been cancelled Details
build / build (Debug, macos-latest, noscripts, cli) (push) Has been cancelled Details
build / build (Debug, ubuntu-latest, lua, cli) (push) Has been cancelled Details
build / build (Debug, ubuntu-latest, noscripts, cli) (push) Has been cancelled Details
build / build (Debug, windows-latest, lua, cli) (push) Has been cancelled Details
build / build (Debug, windows-latest, noscripts, cli) (push) Has been cancelled Details
build / build (RelWithDebInfo, macos-latest, lua, gui) (push) Has been cancelled Details
build / build (RelWithDebInfo, ubuntu-latest, lua, gui) (push) Has been cancelled Details
build / build (RelWithDebInfo, windows-latest, lua, gui) (push) Has been cancelled Details
2025-09-30 08:26:44 -03:00
David Capello f3a372e78e Fix div by zero crash dropping image (fix #5447) 2025-09-30 08:24:50 -03:00
Gaspar Capello 5afa9e6b82 Improper use of pickColor to get the top layer
PickColor was replaced by pickCels in some places in the code because
only the top layer was required; the color was ignored.
Additionally, the RenderPlan for those pickColors (and now pickCels)
was incorrectly initialized for the AutoSelect Layer. Now is fixed.
2025-09-26 17:28:19 -03:00
5 changed files with 25 additions and 21 deletions

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2024 Igara Studio S.A.
// Copyright (C) 2019-2025 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -104,7 +104,7 @@ void ColorPicker::pickColor(const Site& site,
switch (mode) {
// Pick from the composed image
case FromComposition: {
doc::RenderPlan plan(pref.experimental.composeGroups());
doc::RenderPlan plan;
plan.addLayer(sprite->root(), site.frame());
doc::CelList cels;

View File

@ -61,6 +61,7 @@
#include "base/scoped_value.h"
#include "doc/doc.h"
#include "doc/mask_boundaries.h"
#include "doc/render_plan.h"
#include "doc/slice.h"
#include "fmt/format.h"
#include "os/color_space.h"
@ -3097,13 +3098,16 @@ void Editor::updateAutoCelGuides(ui::Message* msg)
// tool to show automatic guides.
if (m_showAutoCelGuides && m_state->allowLayerEdges()) {
auto mouseMsg = dynamic_cast<ui::MouseMessage*>(msg);
ColorPicker picker;
picker.pickColor(getSite(),
screenToEditorF(mouseMsg ? mouseMsg->position() : mousePosInDisplay()),
m_proj,
ColorPicker::FromComposition);
m_showGuidesThisCel = (picker.layer() ? picker.layer()->cel(m_frame) : nullptr);
doc::RenderPlan plan;
Sprite* sprite = getSite().sprite();
plan.addLayer(sprite->root(), getSite().frame());
doc::CelList cels;
sprite->pickCels(screenToEditorF(mouseMsg ? mouseMsg->position() : mousePosInDisplay()),
1,
plan,
cels);
m_showGuidesThisCel =
((!cels.empty() && cels.front()->layer()) ? cels.front()->layer()->cel(m_frame) : nullptr);
}
else {
m_showGuidesThisCel = nullptr;

View File

@ -60,6 +60,7 @@
#include "doc/layer.h"
#include "doc/layer_tilemap.h"
#include "doc/mask.h"
#include "doc/render_plan.h"
#include "doc/slice.h"
#include "doc/sprite.h"
#include "fmt/format.h"
@ -153,16 +154,15 @@ bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg)
// Handle "Auto Select Layer"
if (editor->isAutoSelectLayer()) {
gfx::PointF cursor = editor->screenToEditorF(msg->position());
ColorPicker picker;
picker.pickColor(site, cursor, editor->projection(), ColorPicker::FromComposition);
RenderPlan plan;
plan.addLayer(site.sprite()->root(), site.frame());
doc::CelList cels;
site.sprite()->pickCels(cursor, 1, plan, cels);
const view::RealRange& range = context->range();
if (picker.layer() && !range.contains(picker.layer())) {
layer = picker.layer();
if (layer) {
editor->setLayer(layer);
editor->flashCurrentLayer();
}
if (!cels.empty() && cels.front()->layer() && !range.contains(cels.front()->layer())) {
editor->setLayer(cels.front()->layer());
editor->flashCurrentLayer();
}
}

View File

@ -4631,13 +4631,13 @@ void Timeline::onDrop(ui::DragEvent& e)
std::string txmsg;
std::unique_ptr<docapi::DocProvider> docProvider = nullptr;
if (droppedImage) {
txmsg = "Dropped image on timeline";
txmsg = "Drop Image";
doc::ImageRef image = nullptr;
convert_surface_to_image(surface.get(), 0, 0, surface->width(), surface->height(), image);
docProvider = std::make_unique<DocProviderFromImage>(image);
}
else {
txmsg = "Dropped paths on timeline";
txmsg = "Drop File";
docProvider = std::make_unique<DocProviderFromPaths>(m_document->context(), paths);
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (c) 2024 Igara Studio S.A.
// Copyright (c) 2024-2025 Igara Studio S.A.
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -26,7 +26,7 @@ uint32_t convert_color_to_image(gfx::Color c, const os::SurfaceFormatData* fd)
uint8_t b = ((c & fd->blueMask) >> fd->blueShift);
uint8_t a = ((c & fd->alphaMask) >> fd->alphaShift);
if (fd->pixelAlpha == os::PixelAlpha::kPremultiplied) {
if (a > 0 && fd->pixelAlpha == os::PixelAlpha::kPremultiplied) {
r = r * 255 / a;
g = g * 255 / a;
b = b * 255 / a;