[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: [OT] Any plans to keep up with longhorn?
From: Joachim Eibl <joachim.eibl () gmx ! de>
Date: 2003-11-06 22:58:44
[Download RAW message or body]
> > Well, browsers could include some "intelligent bitmap stretching" algo,
> > which takes resolution into account. It would not be too difficult.
>
> Essentially all it needs is a fast processor and some hefty memory. You
> upsample the image, apply a 2D FIR or IIR filter so that aliasing is
> removed, and you downsample it afterwards. Or a similar algorithm. The
> trick is that your filter should offer a sharp, almost brickboard cutoff.
> If you do it that way, the bitmap scaling is seamless, i.e. your bitmap
> could be scaled by a factor pi:1 and look as good as scaled by a factor
> 2:1.
Before doing that, you might want to try to optimize the little code snippet
below.
Does any KDE-Image viewer support something like this? If not, I hope they
will!
Cheers,
Joachim
/* Copyright (C) Joachim Eibl 2003
Licence: GPL version 2 */
QImage smoothResize( int xSize, int ySize, QImage& inputImg )
{
if( inputImg.isNull() )
return;
QImage outputImg;
outputImg.create(xSize, ySize, 32);
int inWidth = inputImg.width();
int inHeight = inputImg.height();
xFactor = (double)xSize/inWidth;
yFactor = (double)ySize/inHeight;
for ( x=0; x<xSize; ++x )
{
for ( y=0; y<ySize; ++y )
{
double xOrig = x / xFactor;
double yOrig = y / yFactor;
double dx = xOrig - floor( xOrig );
double dy = yOrig - floor( yOrig );
double f1 = (1-dx)*(1-dy); // Interpolation
double f2 = dx * (1-dy);
double f3 = (1-dx)*dy;
double f4 = dx*dy;
int xo = min(int(floor(xOrig)),inWidth-1);
int yo = min(int(floor(yOrig)),inHeight-1);
int xo1 = min(int(floor(xOrig))+1,inWidth-1);
int yo1 = min(int(floor(yOrig))+1,inHeight-1);
QRgb c1 = inputImg.pixel( xo, yo );
QRgb c2 = inputImg.pixel( xo1, yo );
QRgb c3 = inputImg.pixel( xo, yo1 );
QRgb c4 = inputImg.pixel( xo1, yo1 );
int r=int( f1*qRed(c1)+f2*qRed(c2)+f3*qRed(c3)+f4*qRed(c4) );
int g=int( f1*qGreen(c1)+f2*qGreen(c2)+f3*qGreen(c3)+f4*qGreen(c4));
int b=int( f1*qBlue(c1)+f2*qBlue(c2)+f3*qBlue(c3)+f4*qBlue(c4) );
outputImg.setPixel( x,y, qRgb(r,g,b) );
}
}
return outputImg;
}
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic