diff --git a/data/gui.xml b/data/gui.xml index 08e112153..c19364f8f 100644 --- a/data/gui.xml +++ b/data/gui.xml @@ -1,6 +1,6 @@ - + diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 547dc28b5..787d9c4fe 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -234,7 +234,6 @@ add_library(app-lib undoers/set_sprite_pixel_format.cpp undoers/set_sprite_size.cpp undoers/set_sprite_transparent_color.cpp - undoers/set_stock_pixel_format.cpp undoers/set_total_frames.cpp util/autocrop.cpp util/boundary.cpp diff --git a/src/app/commands/cmd_merge_down_layer.cpp b/src/app/commands/cmd_merge_down_layer.cpp index 5c19ab8a3..7581ef557 100644 --- a/src/app/commands/cmd_merge_down_layer.cpp +++ b/src/app/commands/cmd_merge_down_layer.cpp @@ -86,24 +86,25 @@ void MergeDownLayerCommand::onExecute(Context* context) UndoTransaction undo(writer.context(), "Merge Down Layer", undo::ModifyDocument); Layer* src_layer = writer.layer(); Layer* dst_layer = src_layer->getPrevious(); - Cel *src_cel, *dst_cel; - Image *src_image; - base::UniquePtr dst_image; int index; for (FrameNumber frpos(0); frposgetTotalFrames(); ++frpos) { // Get frames - src_cel = static_cast(src_layer)->getCel(frpos); - dst_cel = static_cast(dst_layer)->getCel(frpos); + Cel* src_cel = static_cast(src_layer)->getCel(frpos); + Cel* dst_cel = static_cast(dst_layer)->getCel(frpos); // Get images + Image* src_image; if (src_cel != NULL) src_image = sprite->getStock()->getImage(src_cel->getImage()); else src_image = NULL; + Image* dst_image; if (dst_cel != NULL) - dst_image.reset(sprite->getStock()->getImage(dst_cel->getImage())); + dst_image = sprite->getStock()->getImage(dst_cel->getImage()); + else + dst_image = NULL; // With source image? if (src_image != NULL) { @@ -112,10 +113,10 @@ void MergeDownLayerCommand::onExecute(Context* context) // Copy this cel to the destination layer... // Creating a copy of the image - dst_image.reset(Image::createCopy(src_image)); + dst_image = Image::createCopy(src_image); // Adding it in the stock of images - index = sprite->getStock()->addImage(dst_image.release()); + index = sprite->getStock()->addImage(dst_image); if (undo.isEnabled()) undo.pushUndoer(new undoers::AddImage( undo.getObjects(), sprite->getStock(), index)); @@ -133,7 +134,6 @@ void MergeDownLayerCommand::onExecute(Context* context) // With destination else { int x1, y1, x2, y2; - Image *new_image; // Merge down in the background layer if (dst_layer->isBackground()) { @@ -152,10 +152,10 @@ void MergeDownLayerCommand::onExecute(Context* context) raster::color_t bgcolor = app_get_color_to_clear_layer(dst_layer); - new_image = raster::crop_image(dst_image, - x1-dst_cel->getX(), - y1-dst_cel->getY(), - x2-x1+1, y2-y1+1, bgcolor); + Image* new_image = raster::crop_image(dst_image, + x1-dst_cel->getX(), + y1-dst_cel->getY(), + x2-x1+1, y2-y1+1, bgcolor); // Merge src_image in new_image raster::composite_image(new_image, src_image, @@ -174,6 +174,7 @@ void MergeDownLayerCommand::onExecute(Context* context) sprite->getStock(), dst_cel->getImage())); sprite->getStock()->replaceImage(dst_cel->getImage(), new_image); + delete dst_image; } } } diff --git a/src/app/document_api.cpp b/src/app/document_api.cpp index 56b0508c0..3c8141208 100644 --- a/src/app/document_api.cpp +++ b/src/app/document_api.cpp @@ -56,7 +56,6 @@ #include "app/undoers/set_sprite_pixel_format.h" #include "app/undoers/set_sprite_size.h" #include "app/undoers/set_sprite_transparent_color.h" -#include "app/undoers/set_stock_pixel_format.h" #include "app/undoers/set_total_frames.h" #include "base/unique_ptr.h" #include "raster/algorithm/flip_image.h" @@ -161,12 +160,6 @@ void DocumentApi::setPixelFormat(Sprite* sprite, PixelFormat newFormat, Ditherin if (sprite->getPixelFormat() == newFormat) return; - // Change pixel format of the stock of images. - if (undoEnabled()) - m_undoers->pushUndoer(new undoers::SetStockPixelFormat(getObjects(), sprite->getStock())); - - sprite->getStock()->setPixelFormat(newFormat); - // TODO Review this, why we use the palette in frame 0? FrameNumber frame(0); diff --git a/src/app/undoers/set_stock_pixel_format.cpp b/src/app/undoers/set_stock_pixel_format.cpp deleted file mode 100644 index 60afabca4..000000000 --- a/src/app/undoers/set_stock_pixel_format.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* Aseprite - * Copyright (C) 2001-2013 David Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "app/undoers/set_stock_pixel_format.h" - -#include "raster/stock.h" -#include "undo/objects_container.h" -#include "undo/undoers_collector.h" - -namespace app { -namespace undoers { - -using namespace raster; -using namespace undo; - -SetStockPixelFormat::SetStockPixelFormat(ObjectsContainer* objects, Stock* stock) - : m_stockId(objects->addObject(stock)) - , m_format(stock->getPixelFormat()) -{ -} - -void SetStockPixelFormat::dispose() -{ - delete this; -} - -void SetStockPixelFormat::revert(ObjectsContainer* objects, UndoersCollector* redoers) -{ - Stock* stock = objects->getObjectT(m_stockId); - - // Push another SetStockPixelFormat as redoer - redoers->pushUndoer(new SetStockPixelFormat(objects, stock)); - - stock->setPixelFormat(static_cast(m_format)); -} - -} // namespace undoers -} // namespace app diff --git a/src/app/undoers/set_stock_pixel_format.h b/src/app/undoers/set_stock_pixel_format.h deleted file mode 100644 index 0c91f8134..000000000 --- a/src/app/undoers/set_stock_pixel_format.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Aseprite - * Copyright (C) 2001-2013 David Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef APP_UNDOERS_SET_STOCK_PIXEL_FORMAT_H_INCLUDED -#define APP_UNDOERS_SET_STOCK_PIXEL_FORMAT_H_INCLUDED -#pragma once - -#include "app/undoers/undoer_base.h" -#include "undo/object_id.h" - -namespace raster { - class Stock; -} - -namespace app { - namespace undoers { - using namespace raster; - using namespace undo; - - class SetStockPixelFormat : public UndoerBase { - public: - SetStockPixelFormat(ObjectsContainer* objects, Stock* stock); - - void dispose() OVERRIDE; - size_t getMemSize() const OVERRIDE { return sizeof(*this); } - void revert(ObjectsContainer* objects, UndoersCollector* redoers) OVERRIDE; - - private: - ObjectId m_stockId; - uint32_t m_format; - }; - - } // namespace undoers -} // namespace app - -#endif // UNDOERS_SET_STOCK_PIXEL_FORMAT_H_INCLUDED diff --git a/src/app/util/render.cpp b/src/app/util/render.cpp index 18cdc9f6d..2b43af1ef 100644 --- a/src/app/util/render.cpp +++ b/src/app/util/render.cpp @@ -600,7 +600,7 @@ void RenderEngine::renderLayer( output_opacity = MID(0, cel->getOpacity(), 255); output_opacity = INT_MULT(output_opacity, global_opacity, t); - src_image->setMaskColor(m_sprite->getTransparentColor()); + ASSERT(src_image->getMaskColor() == m_sprite->getTransparentColor()); (*zoomed_func)(image, src_image, m_sprite->getPalette(frame), (cel->getX() << zoom) - source_x, diff --git a/src/config.h b/src/config.h index aee27735b..7d3b02cee 100644 --- a/src/config.h +++ b/src/config.h @@ -33,7 +33,7 @@ // General information #define PACKAGE "Aseprite" -#define VERSION "1.0.0-dev" +#define VERSION "1.0.1-dev" #ifdef CUSTOM_WEBSITE_URL #define WEBSITE CUSTOM_WEBSITE_URL // To test web server #else diff --git a/src/main/resources_win32.rc b/src/main/resources_win32.rc index df1822b80..08712e500 100644 --- a/src/main/resources_win32.rc +++ b/src/main/resources_win32.rc @@ -1,8 +1,8 @@ allegro_icon ICON data/icons/ase.ico 1 VERSIONINFO - FILEVERSION 1,0,0,0 - PRODUCTVERSION 1,0,0,0 + FILEVERSION 1,0,1,0 + PRODUCTVERSION 1,0,1,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -19,12 +19,12 @@ BEGIN BEGIN VALUE "Comments", "http://aseprite.org/" VALUE "FileDescription", "Aseprite - Animated sprites editor & pixel art tool" - VALUE "FileVersion", "1,0,0,0" + VALUE "FileVersion", "1,0,1,0" VALUE "InternalName", "aseprite" VALUE "LegalCopyright", "Copyright (C) 2001-2014 by David Capello" VALUE "OriginalFilename", "aseprite.exe" VALUE "ProductName", "ASEPRITE" - VALUE "ProductVersion", "1,0,0,0" + VALUE "ProductVersion", "1,0,1,0" END END BLOCK "VarFileInfo" diff --git a/src/raster/layer.cpp b/src/raster/layer.cpp index 6e7fd3f05..9f7208042 100644 --- a/src/raster/layer.cpp +++ b/src/raster/layer.cpp @@ -325,7 +325,7 @@ void layer_render(const Layer* layer, Image* image, int x, int y, FrameNumber fr src_image = layer->getSprite()->getStock()->getImage(cel->getImage()); ASSERT(src_image != NULL); - src_image->setMaskColor(layer->getSprite()->getTransparentColor()); + ASSERT(src_image->getMaskColor() == layer->getSprite()->getTransparentColor()); composite_image(image, src_image, cel->getX() + x, diff --git a/src/raster/sprite.cpp b/src/raster/sprite.cpp index bbd9e6149..bd832c7d3 100644 --- a/src/raster/sprite.cpp +++ b/src/raster/sprite.cpp @@ -50,7 +50,7 @@ Sprite::Sprite(PixelFormat format, int width, int height, int ncolors) ASSERT(width > 0 && height > 0); m_frlens.push_back(100); // First frame with 100 msecs of duration - m_stock = new Stock(format); + m_stock = new Stock(this, format); m_folder = new LayerFolder(this); // Generate palette @@ -136,6 +136,7 @@ void Sprite::setTransparentColor(color_t color) { m_transparentColor = color; + // Change the mask color of all images. for (int i=0; isize(); i++) { Image* image = m_stock->getImage(i); if (image != NULL) diff --git a/src/raster/stock.cpp b/src/raster/stock.cpp index f2635f265..42002aa3f 100644 --- a/src/raster/stock.cpp +++ b/src/raster/stock.cpp @@ -23,44 +23,21 @@ #include "raster/stock.h" #include "raster/image.h" +#include "raster/sprite.h" #include namespace raster { -Stock::Stock(PixelFormat format) +Stock::Stock(Sprite* sprite, PixelFormat format) : Object(OBJECT_STOCK) + , m_sprite(sprite) , m_format(format) { // Image with index=0 is always NULL. m_image.push_back(NULL); } -Stock::Stock(const Stock& stock) - : Object(stock) - , m_format(stock.getPixelFormat()) -{ - try { - for (int i=0; i 0) && (index < size())); m_image[index] = image; + + fixupImage(image); +} + +void Stock::fixupImage(Image* image) +{ + // Change the mask color of the added image to the sprite mask color. + if (image) + image->setMaskColor(m_sprite->getTransparentColor()); } } // namespace raster diff --git a/src/raster/stock.h b/src/raster/stock.h index 0c8c94aac..b556ec8e4 100644 --- a/src/raster/stock.h +++ b/src/raster/stock.h @@ -20,6 +20,7 @@ #define RASTER_STOCK_H_INCLUDED #pragma once +#include "base/disable_copying.h" #include "raster/object.h" #include "raster/pixel_format.h" @@ -28,17 +29,16 @@ namespace raster { class Image; + class Sprite; typedef std::vector ImagesList; class Stock : public Object { public: - Stock(PixelFormat format); - Stock(const Stock& stock); + Stock(Sprite* sprite, PixelFormat format); virtual ~Stock(); - PixelFormat getPixelFormat() const; - void setPixelFormat(PixelFormat format); + Sprite* getSprite() const; // Returns the number of image in the stock. int size() const { @@ -66,9 +66,15 @@ namespace raster { // void replaceImage(int index, Image* image); - //private: TODO uncomment this line + private: + void fixupImage(Image* image); + PixelFormat m_format; // Type of images (all images in the stock must be of this type). ImagesList m_image; // The images-array where the images are. + Sprite* m_sprite; + + Stock(); + DISABLE_COPYING(Stock); }; } // namespace raster