- Fixed calculation of stride for image scaling and color manipulation (STR #1673)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5825 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
62d66c6422
commit
08c5fb6ff4
2
CHANGES
2
CHANGES
@ -3,6 +3,8 @@ CHANGES IN FLTK 1.1.8
|
||||
- Documentation fixes (STR #1454, STR #1455, STR #1456,
|
||||
STR #1457, STR #1458, STR #1460, STR #1481, STR #1578,
|
||||
STR #1639, STR #1645, STR #1644)
|
||||
- Fixed calculation of stride for image scaling and
|
||||
color manipulation (STR #1673)
|
||||
- Made -O3 the default optimization on Cygwin/Mingw since
|
||||
-Os currently creates bad code (STR #1656)
|
||||
- OSF/Tru64 now uses 'install-sh' instead of 'install' to
|
||||
|
@ -186,7 +186,8 @@ Fl_Image *Fl_RGB_Image::copy(int W, int H) {
|
||||
dx, dy, // Destination coordinates
|
||||
xerr, yerr, // X & Y errors
|
||||
xmod, ymod, // X & Y moduli
|
||||
xstep, ystep; // X & Y step increments
|
||||
xstep, ystep, // X & Y step increments
|
||||
line_d; // stride from line to line
|
||||
|
||||
|
||||
// Figure out Bresenheim step/modulus values...
|
||||
@ -194,6 +195,7 @@ Fl_Image *Fl_RGB_Image::copy(int W, int H) {
|
||||
xstep = (w() / W) * d();
|
||||
ymod = h() % H;
|
||||
ystep = h() / H;
|
||||
line_d = ld() ? ld() : w() * d();
|
||||
|
||||
// Allocate memory for the new image...
|
||||
new_array = new uchar [W * H * d()];
|
||||
@ -202,9 +204,7 @@ Fl_Image *Fl_RGB_Image::copy(int W, int H) {
|
||||
|
||||
// Scale the image using a nearest-neighbor algorithm...
|
||||
for (dy = H, sy = 0, yerr = H, new_ptr = new_array; dy > 0; dy --) {
|
||||
for (dx = W, xerr = W, old_ptr = array + sy * (w() * d() + ld());
|
||||
dx > 0;
|
||||
dx --) {
|
||||
for (dx = W, xerr = W, old_ptr = array + sy * line_d; dx > 0; dx --) {
|
||||
for (c = 0; c < d(); c ++) *new_ptr++ = old_ptr[c];
|
||||
|
||||
old_ptr += xstep;
|
||||
@ -257,17 +257,18 @@ void Fl_RGB_Image::color_average(Fl_Color c, float i) {
|
||||
// Update the image data to do the blend...
|
||||
const uchar *old_ptr;
|
||||
int x, y;
|
||||
int line_i = ld() ? ld() - (w()*d()) : 0; // increment from line end to beginning of next line
|
||||
|
||||
if (d() < 3) {
|
||||
ig = (r * 31 + g * 61 + b * 8) / 100 * (256 - ia);
|
||||
|
||||
for (new_ptr = new_array, old_ptr = array, y = 0; y < h(); y ++, old_ptr += ld())
|
||||
for (new_ptr = new_array, old_ptr = array, y = 0; y < h(); y ++, old_ptr += line_i)
|
||||
for (x = 0; x < w(); x ++) {
|
||||
*new_ptr++ = (*old_ptr++ * ia + ig) >> 8;
|
||||
if (d() > 1) *new_ptr++ = *old_ptr++;
|
||||
}
|
||||
} else {
|
||||
for (new_ptr = new_array, old_ptr = array, y = 0; y < h(); y ++, old_ptr += ld())
|
||||
for (new_ptr = new_array, old_ptr = array, y = 0; y < h(); y ++, old_ptr += line_i)
|
||||
for (x = 0; x < w(); x ++) {
|
||||
*new_ptr++ = (*old_ptr++ * ia + ir) >> 8;
|
||||
*new_ptr++ = (*old_ptr++ * ia + ig) >> 8;
|
||||
@ -306,8 +307,9 @@ void Fl_RGB_Image::desaturate() {
|
||||
// Copy the image data, converting to grayscale...
|
||||
const uchar *old_ptr;
|
||||
int x, y;
|
||||
int line_i = ld() ? ld() - (w()*d()) : 0; // increment from line end to beginning of next line
|
||||
|
||||
for (new_ptr = new_array, old_ptr = array, y = 0; y < h(); y ++, old_ptr += ld())
|
||||
for (new_ptr = new_array, old_ptr = array, y = 0; y < h(); y ++, old_ptr += line_i)
|
||||
for (x = 0; x < w(); x ++, old_ptr += d()) {
|
||||
*new_ptr++ = (uchar)((31 * old_ptr[0] + 61 * old_ptr[1] + 8 * old_ptr[2]) / 100);
|
||||
if (d() > 3) *new_ptr++ = old_ptr[3];
|
||||
|
Loading…
Reference in New Issue
Block a user