Skip to content

Instantly share code, notes, and snippets.

@donSchoe
Created May 9, 2013 18:00
Show Gist options
  • Save donSchoe/5549273 to your computer and use it in GitHub Desktop.
Save donSchoe/5549273 to your computer and use it in GitHub Desktop.
wo ist der fehler?
// dither()
float p11 = image[w * y + x];
float sw11 = 1.f;
if(p11 < 0.5) sw11 = 0.f;
float qe = p11 - sw11;
float p12 = image[w * y + _clamp(0, w, (x + 1))];
float p20 = image[_clamp(0, h, (w * (y + 1))) + _clamp(0, w, (x - 1))];
float p21 = image[_clamp(0, h, (w * (y + 1))) + x];
float p22 = image[_clamp(0, h, (w * (y + 1))) + _clamp(0, w, (x + 1))];
image[w * y + _clamp(0, w, (x + 1))] = p12 + 7 * qe / 16.f;
image[_clamp(0, h, (w * (y + 1))) + _clamp(0, w, (x - 1))] = p20 + 3 * qe / 16.f;
image[_clamp(0, h, (w * (y + 1))) + x] = p21 + 2 * qe / 16.f;
image[_clamp(0, h, (w * (y + 1))) + _clamp(0, w, (x + 1))] = p22 + 1 * qe / 16.f;
image[w * y + x] = sw11;
// initialize()
// [...]
float * imagef = new float[w * h];
for(int y = 0; y < h; ++y)
for(int x = 0; x < w; ++x) {
QColor c11(image.pixel(x, y));
imagef[y * w + x] = c11.valueF();
}
for(int y = 0; y < h; ++y)
for(int x = 0; x < w; ++x)
dither(imagef, x, y, w, h);
for(int y = 0; y < h; ++y)
for(int x = 0; x < w; ++x)
{
image.setPixel(x, y, imagef[w * y + x]);
}
delete imagef;
m_dithered = new QGraphicsPixmapItem(QPixmap::fromImage(image));
// [...]
@donSchoe
Copy link
Author

donSchoe commented May 9, 2013

zeile 36

@donSchoe
Copy link
Author

zeile 13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment