|
|
| version 1.19, 2001/10/16 10:26:09 | version 1.22, 2001/11/05 11:46:22 |
|---|---|
| Line 2 | Line 2 |
| Parser: image manipulations impl1. | Parser: image manipulations impl1. |
| Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf) | Author: Alexander Petrosyan <paf@design.ru> (http://paf.design.ru) |
| $Id$ | $Id$ |
| Line 20 | Line 20 |
| #include "gif.h" | #include "gif.h" |
| #include "mtables.h" | #include "mtables.h" |
| #include "pa_common.h" | |
| //static void BrushApply(int x, int y); | //static void BrushApply(int x, int y); |
| //static void TileApply(int x, int y); | //static void TileApply(int x, int y); |
| Line 642 void gdImage::Copy(gdImage& dst, int dst | Line 643 void gdImage::Copy(gdImage& dst, int dst |
| } | } |
| } | } |
| static double round(double param) { return floor(param+0.5); } | |
| void gdImage::CopyResampled(gdImage& dst, | void gdImage::CopyResampled(gdImage& dst, |
| int dstX, int dstY, | int dstX, int dstY, |
| int srcX, int srcY, | int srcX, int srcY, |
| Line 659 void gdImage::CopyResampled(gdImage& dst | Line 659 void gdImage::CopyResampled(gdImage& dst |
| if (src.GetTransparent() == pd) | if (src.GetTransparent() == pd) |
| continue; | continue; |
| float sy1, sy2, sx1, sx2; | double sy1, sy2, sx1, sx2; |
| float sx, sy; | double sx, sy; |
| float spixels = 0; | double spixels = 0; |
| float red = 0.0, green = 0.0, blue = 0.0; | double red = 0.0, green = 0.0, blue = 0.0; |
| sy1 = ((float) y - (float) dstY) * (float) srcH / | sy1 = ((double) y - (double) dstY) * (double) srcH / |
| (float) dstH; | (double) dstH; |
| sy2 = ((float) (y + 1) - (float) dstY) * (float) srcH / | sy2 = ((double) (y + 1) - (double) dstY) * (double) srcH / |
| (float) dstH; | (double) dstH; |
| sy = sy1; | sy = sy1; |
| do | do |
| { | { |
| float yportion; | double yportion; |
| if (floor (sy) == floor (sy1)) | if (floor (sy) == floor (sy1)) |
| { | { |
| yportion = 1.0 - (sy - floor (sy)); | yportion = 1.0 - (sy - floor (sy)); |
| Line 688 void gdImage::CopyResampled(gdImage& dst | Line 688 void gdImage::CopyResampled(gdImage& dst |
| { | { |
| yportion = 1.0; | yportion = 1.0; |
| } | } |
| sx1 = ((float) x - (float) dstX) * (float) srcW / | sx1 = ((double) x - (double) dstX) * (double) srcW / |
| dstW; | dstW; |
| sx2 = ((float) (x + 1) - (float) dstX) * (float) srcW / | sx2 = ((double) (x + 1) - (double) dstX) * (double) srcW / |
| dstW; | dstW; |
| sx = sx1; | sx = sx1; |
| do | do |
| { | { |
| float xportion; | double xportion; |
| float pcontribution; | double pcontribution; |
| int p; | int p; |
| if (floor (sx) == floor (sx1)) | if (floor (sx) == floor (sx1)) |
| { | { |
| Line 744 void gdImage::CopyResampled(gdImage& dst | Line 744 void gdImage::CopyResampled(gdImage& dst |
| green=round(green); | green=round(green); |
| blue=round(blue); | blue=round(blue); |
| /* First look for an exact match */ | /* First look for an exact match */ |
| int nc = dst.ColorExact(red, green, blue); | int nc = dst.ColorExact((int)red, (int)green, (int)blue); |
| if (nc == (-1)) { | if (nc == (-1)) { |
| /* No, so go for the closest color with high tolerance */ | /* No, so go for the closest color with high tolerance */ |
| nc = dst.ColorClosest(red, green, blue, tolerance); | nc = dst.ColorClosest((int)red, (int)green, (int)blue, tolerance); |
| if (nc == (-1)) { | if (nc == (-1)) { |
| /* Not found with even high tolerance, so try to allocate it */ | /* Not found with even high tolerance, so try to allocate it */ |
| nc = dst.ColorAllocate(red, green,blue); | nc = dst.ColorAllocate((int)red, (int)green, (int)blue); |
| /* If we're out of colors, go for the closest color */ | /* If we're out of colors, go for the closest color */ |
| if (nc == (-1)) | if (nc == (-1)) |
| nc = dst.ColorClosest(red, green, blue); | nc = dst.ColorClosest((int)red, (int)green, (int)blue); |
| } | } |
| } | } |
| dst.SetPixel(x, y, nc); | dst.SetPixel(x, y, nc); |