mirror of
https://github.com/fltk/fltk.git
synced 2026-05-30 21:25:30 +08:00
Fix typos, separate local variables of image scaling algorithms.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11869 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
+1
-1
@@ -189,7 +189,7 @@ Fl_Image *Fl_Bitmap::copy(int W, int H) {
|
|||||||
xstep, ystep; // X & Y step increments
|
xstep, ystep; // X & Y step increments
|
||||||
|
|
||||||
|
|
||||||
// Figure out Bresenheim step/modulus values...
|
// Figure out Bresenham step/modulus values...
|
||||||
xmod = w() % W;
|
xmod = w() % W;
|
||||||
xstep = w() / W;
|
xstep = w() / W;
|
||||||
ymod = h() % H;
|
ymod = h() % H;
|
||||||
|
|||||||
+18
-17
@@ -63,7 +63,6 @@ void Fl_Image::draw(int XP, int YP, int, int, int, int) {
|
|||||||
draw_empty(XP, YP);
|
draw_empty(XP, YP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The protected method draw_empty() draws a box with
|
The protected method draw_empty() draws a box with
|
||||||
an X in it. It can be used to draw any image that lacks image
|
an X in it. It can be used to draw any image that lacks image
|
||||||
@@ -324,31 +323,33 @@ Fl_Image *Fl_RGB_Image::copy(int W, int H) {
|
|||||||
}
|
}
|
||||||
if (W <= 0 || H <= 0) return 0;
|
if (W <= 0 || H <= 0) return 0;
|
||||||
|
|
||||||
// OK, need to resize the image data; allocate memory and
|
// OK, need to resize the image data; allocate memory and create new image
|
||||||
uchar *new_ptr; // Pointer into new array
|
uchar *new_ptr; // Pointer into new array
|
||||||
const uchar *old_ptr; // Pointer into old array
|
const uchar *old_ptr; // Pointer into old array
|
||||||
int c, // Channel number
|
int dx, dy, // Destination coordinates
|
||||||
sy, // Source coordinate
|
line_d; // stride from line to line
|
||||||
dx, dy, // Destination coordinates
|
|
||||||
xerr, yerr, // X & Y errors
|
|
||||||
xmod, ymod, // X & Y moduli
|
|
||||||
xstep, ystep, // X & Y step increments
|
|
||||||
line_d; // stride from line to line
|
|
||||||
|
|
||||||
|
|
||||||
// Figure out Bresenheim step/modulus values...
|
|
||||||
xmod = w() % W;
|
|
||||||
xstep = (w() / W) * d();
|
|
||||||
ymod = h() % H;
|
|
||||||
ystep = h() / H;
|
|
||||||
line_d = ld() ? ld() : w() * d();
|
|
||||||
|
|
||||||
// Allocate memory for the new image...
|
// Allocate memory for the new image...
|
||||||
new_array = new uchar [W * H * d()];
|
new_array = new uchar [W * H * d()];
|
||||||
new_image = new Fl_RGB_Image(new_array, W, H, d());
|
new_image = new Fl_RGB_Image(new_array, W, H, d());
|
||||||
new_image->alloc_array = 1;
|
new_image->alloc_array = 1;
|
||||||
|
|
||||||
|
line_d = ld() ? ld() : w() * d();
|
||||||
|
|
||||||
if (Fl_Image::RGB_scaling() == FL_RGB_SCALING_NEAREST) {
|
if (Fl_Image::RGB_scaling() == FL_RGB_SCALING_NEAREST) {
|
||||||
|
|
||||||
|
int c, // Channel number
|
||||||
|
sy, // Source coordinate
|
||||||
|
xerr, yerr, // X & Y errors
|
||||||
|
xmod, ymod, // X & Y moduli
|
||||||
|
xstep, ystep; // X & Y step increments
|
||||||
|
|
||||||
|
// Figure out Bresenham step/modulus values...
|
||||||
|
xmod = w() % W;
|
||||||
|
xstep = (w() / W) * d();
|
||||||
|
ymod = h() % H;
|
||||||
|
ystep = h() / H;
|
||||||
|
|
||||||
// Scale the image using a nearest-neighbor algorithm...
|
// Scale the image using a nearest-neighbor algorithm...
|
||||||
for (dy = H, sy = 0, yerr = H, new_ptr = new_array; dy > 0; dy --) {
|
for (dy = H, sy = 0, yerr = H, new_ptr = new_array; dy > 0; dy --) {
|
||||||
for (dx = W, xerr = W, old_ptr = array + sy * line_d; dx > 0; dx --) {
|
for (dx = W, xerr = W, old_ptr = array + sy * line_d; dx > 0; dx --) {
|
||||||
|
|||||||
+1
-1
@@ -204,7 +204,7 @@ Fl_Image *Fl_Pixmap::copy(int W, int H) {
|
|||||||
|
|
||||||
sprintf(new_info, "%d %d %d %d", W, H, ncolors, chars_per_pixel);
|
sprintf(new_info, "%d %d %d %d", W, H, ncolors, chars_per_pixel);
|
||||||
|
|
||||||
// Figure out Bresenheim step/modulus values...
|
// Figure out Bresenham step/modulus values...
|
||||||
xmod = w() % W;
|
xmod = w() % W;
|
||||||
xstep = (w() / W) * chars_per_pixel;
|
xstep = (w() / W) * chars_per_pixel;
|
||||||
ymod = h() % H;
|
ymod = h() % H;
|
||||||
|
|||||||
Reference in New Issue
Block a user