mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-04 08:46:09 +00:00
Fix Image::getRowStrideSize() function (fixes crash reported in issue 443)
This commit is contained in:
parent
7faf8a1bb7
commit
3bbdb80461
@ -27,6 +27,8 @@
|
|||||||
#include "undo/undo_exception.h"
|
#include "undo/undo_exception.h"
|
||||||
#include "undo/undoers_collector.h"
|
#include "undo/undoers_collector.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace undoers {
|
namespace undoers {
|
||||||
|
|
||||||
@ -42,8 +44,12 @@ ImageArea::ImageArea(ObjectsContainer* objects, Image* image, int x, int y, int
|
|||||||
ASSERT(w >= 1 && h >= 1);
|
ASSERT(w >= 1 && h >= 1);
|
||||||
ASSERT(x >= 0 && y >= 0 && x+w <= image->width() && y+h <= image->height());
|
ASSERT(x >= 0 && y >= 0 && x+w <= image->width() && y+h <= image->height());
|
||||||
|
|
||||||
for (int v=0; v<h; ++v)
|
std::vector<uint8_t>::iterator it = m_data.begin();
|
||||||
memcpy(&m_data[m_lineSize*v], image->getPixelAddress(x, y+v), m_lineSize);
|
for (int v=0; v<h; ++v) {
|
||||||
|
uint8_t* addr = image->getPixelAddress(x, y+v);
|
||||||
|
std::copy(addr, addr+m_lineSize, it);
|
||||||
|
it += m_lineSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageArea::dispose()
|
void ImageArea::dispose()
|
||||||
@ -62,8 +68,12 @@ void ImageArea::revert(ObjectsContainer* objects, UndoersCollector* redoers)
|
|||||||
redoers->pushUndoer(new ImageArea(objects, image, m_x, m_y, m_w, m_h));
|
redoers->pushUndoer(new ImageArea(objects, image, m_x, m_y, m_w, m_h));
|
||||||
|
|
||||||
// Restore the old image portion
|
// Restore the old image portion
|
||||||
for (int v=0; v<m_h; ++v)
|
std::vector<uint8_t>::iterator it = m_data.begin();
|
||||||
memcpy(image->getPixelAddress(m_x, m_y+v), &m_data[m_lineSize*v], m_lineSize);
|
for (int v=0; v<m_h; ++v) {
|
||||||
|
uint8_t* addr = image->getPixelAddress(m_x, m_y+v);
|
||||||
|
std::copy(it, it+m_lineSize, addr);
|
||||||
|
it += m_lineSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace undoers
|
} // namespace undoers
|
||||||
|
@ -57,7 +57,7 @@ int Image::getRowStrideSize() const
|
|||||||
|
|
||||||
int Image::getRowStrideSize(int pixels_per_row) const
|
int Image::getRowStrideSize(int pixels_per_row) const
|
||||||
{
|
{
|
||||||
return calculate_rowstride_bytes(pixelFormat(), m_width);
|
return calculate_rowstride_bytes(pixelFormat(), pixels_per_row);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
Loading…
Reference in New Issue
Block a user