Anonymous user
Color quantization: Difference between revisions
Shorter second D entry
(Improved names in second D entry) |
(Shorter second D entry) |
||
Line 288:
import std.exception: enforce;
import std.array: empty;
import std.typetuple: TypeTuple;
enum ON_INHEAP = 1;
Line 612 ⟶ 613:
assert(npx != null);
auto pix = im.pix.ptr;
alias triple = TypeTuple!(0, 1, 2);
for (auto px = npx, i = 0u; i < im.h; i++) {
for (uint j = 0; j < im.w; j++, pix += 3, px += 3) {
px[
}
}
Line 630 ⟶ 631:
for (auto px = npx, i = 0u; i < im.h; i++) {
for (uint j = 0; j < im.w; j++, pix += 3, px += 3) {
px[
clamp(px[
const nd = nearestColor(px);
Line 648 ⟶ 647:
if (j < im.w - 1) {
npx[pos(i, j + 1) +
}
Line 656 ⟶ 654:
continue;
npx[pos(i + 1, j) +
if (j < im.w - 1) {
npx[pos(i + 1, j + 1) +
}
if (j) {
npx[pos(i + 1, j - 1) +
}
}
|