mirror of https://github.com/aseprite/aseprite.git
Fix transposed arg, add consts
This commit is contained in:
parent
484f8d69bf
commit
4c5f5249d8
|
@ -583,11 +583,13 @@ void ChangePixelFormatCommand::onExecute(Context* ctx)
|
||||||
if (window.closer() != window.ok())
|
if (window.closer() != window.ok())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const auto d = window.dithering();
|
||||||
|
|
||||||
params().colorMode(window.selectedColorMode());
|
params().colorMode(window.selectedColorMode());
|
||||||
params().dithering(window.dithering().algorithm());
|
params().dithering(d.algorithm());
|
||||||
matrix = window.dithering().matrix();
|
matrix = d.matrix();
|
||||||
params().factor(window.dithering().factor());
|
params().factor(d.factor());
|
||||||
params().zigZag(window.dithering().zigzag());
|
params().zigZag(d.zigzag());
|
||||||
params().rgbmap(window.rgbMapAlgorithm());
|
params().rgbmap(window.rgbMapAlgorithm());
|
||||||
params().fitCriteria(window.fitCriteria());
|
params().fitCriteria(window.fitCriteria());
|
||||||
params().toGray(window.toGray());
|
params().toGray(window.toGray());
|
||||||
|
@ -634,7 +636,7 @@ void ChangePixelFormatCommand::onExecute(Context* ctx)
|
||||||
tx(new cmd::SetPixelFormat(
|
tx(new cmd::SetPixelFormat(
|
||||||
sprite,
|
sprite,
|
||||||
(PixelFormat)params().colorMode(),
|
(PixelFormat)params().colorMode(),
|
||||||
render::Dithering(params().dithering(), matrix, params().factor(), params().zigZag()),
|
render::Dithering(params().dithering(), matrix, params().zigZag(), params().factor()),
|
||||||
params().rgbmap(),
|
params().rgbmap(),
|
||||||
get_gray_func(params().toGray()),
|
get_gray_func(params().toGray()),
|
||||||
&job, // SpriteJob is a render::TaskDelegate
|
&job, // SpriteJob is a render::TaskDelegate
|
||||||
|
|
|
@ -142,7 +142,7 @@ void ErrorDiffusionDither::start(const doc::Image* srcImage,
|
||||||
const int bufferRows = matrix.height;
|
const int bufferRows = matrix.height;
|
||||||
|
|
||||||
// Resize error buffers to accommodate the matrix height
|
// Resize error buffers to accommodate the matrix height
|
||||||
std::vector<int>::size_type bufferSize = m_width * bufferRows;
|
const std::vector<int>::size_type bufferSize = m_width * bufferRows;
|
||||||
for (int i = 0; i < kChannels; ++i)
|
for (int i = 0; i < kChannels; ++i)
|
||||||
m_err[i].resize(bufferSize, 0);
|
m_err[i].resize(bufferSize, 0);
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ doc::color_t ErrorDiffusionDither::ditherRgbToIndex2D(const int x,
|
||||||
m_currentRowOffset = (m_currentRowOffset + 1) % matrix.height;
|
m_currentRowOffset = (m_currentRowOffset + 1) % matrix.height;
|
||||||
|
|
||||||
// Clear only the row that will be used as the "last" row
|
// Clear only the row that will be used as the "last" row
|
||||||
int clearRowIndex = (m_currentRowOffset + matrix.height - 1) % matrix.height;
|
const int clearRowIndex = (m_currentRowOffset + matrix.height - 1) % matrix.height;
|
||||||
for (int c = 0; c < kChannels; ++c) {
|
for (int c = 0; c < kChannels; ++c) {
|
||||||
int* rowToClear = &m_err[c][m_width * clearRowIndex];
|
int* rowToClear = &m_err[c][m_width * clearRowIndex];
|
||||||
std::fill(rowToClear, rowToClear + m_width, 0);
|
std::fill(rowToClear, rowToClear + m_width, 0);
|
||||||
|
@ -215,8 +215,8 @@ doc::color_t ErrorDiffusionDither::ditherRgbToIndex2D(const int x,
|
||||||
|
|
||||||
for (int my = 0; my < matrix.height; ++my) {
|
for (int my = 0; my < matrix.height; ++my) {
|
||||||
// Use circular buffer indexing
|
// Use circular buffer indexing
|
||||||
int bufferRow = (m_currentRowOffset + my) % matrix.height;
|
const int bufferRow = (m_currentRowOffset + my) % matrix.height;
|
||||||
int bufferRowIndex = bufferRow * m_width;
|
const int bufferRowIndex = bufferRow * m_width;
|
||||||
|
|
||||||
for (int mx = 0; mx < matrix.width; ++mx) {
|
for (int mx = 0; mx < matrix.width; ++mx) {
|
||||||
const int coeff = direction > 0 ? matrix.coefficients[my][mx] : matrix.coefficients[my][matrix.width - 1 - mx];
|
const int coeff = direction > 0 ? matrix.coefficients[my][mx] : matrix.coefficients[my][matrix.width - 1 - mx];
|
||||||
|
@ -234,9 +234,6 @@ doc::color_t ErrorDiffusionDither::ditherRgbToIndex2D(const int x,
|
||||||
|
|
||||||
// Calculate error as 16-bit fixed point
|
// Calculate error as 16-bit fixed point
|
||||||
const int errorValue = ((qerr * coeff) << 16) / matrix.divisor;
|
const int errorValue = ((qerr * coeff) << 16) / matrix.divisor;
|
||||||
const int bufferRow = my;
|
|
||||||
const int bufferIndex = bufferRow * m_width + errorPixelX + 1;
|
|
||||||
|
|
||||||
m_err[c][bufferRowIndex + errorPixelX + 1] += errorValue;
|
m_err[c][bufferRowIndex + errorPixelX + 1] += errorValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue