>>57968731
you're so fucking lazy i bet you play videogames
for (int i=0;i<h2;i++)
{
int* t = temp + i*w2;
y2 = ((i*y_ratio)>>16);
int* p = pixels + y2*w1;
int rat = 0;
for (int j=0;j<w2;j++)
{
x2 = (rat>>16);
*t++ = p[x2];
rat += x_ratio;
}
}
another one in matlab:
function [ scaledImg ] = imgResize( inputImg, rows, cols, factor )
scaledImg=zeros(rows*factor,cols*factor);
tic
for i=1:(rows*factor)
for j=1:(cols*factor)
x=floor(i/factor);
y=floor(j/factor);
if x==0
x=1;
end
if y==0
y=1;
end
scaledImg(i,j) = inputImg(x,y);
end
end
toc
figure(1);imshow(inputImg, []);
figure(2);imshow(scaledImg, []);
end
another one in c sharp:
ublic static Bitmap NearestNeighborScale(Bitmap bmp, int newXSize, int newYSize)
{
if (newXSize == 0 || newYSize==0)
throw new ImageException(\"New dimensions cannot be zero for scaling!\");
Bitmap newBMP = new Bitmap(newXSize, newYSize);
int w1 = bmp.Width;
int h1 = bmp.Height;
// EDIT: added +1 to account for an early rounding problem
int x_ratio = (int)((w1 << 16) / newXSize) + 1;
int y_ratio = (int)((h1 << 16) / newYSize) + 1;
int x2, y2;
for (int i = 0; i < newYSize; i++)
{
for (int j = 0; j < newXSize; j++)
{
//Get the source position of the pixel
x2 = ((j * x_ratio) >> 16);
y2 = ((i * y_ratio) >> 16);
newBMP.SetPixel(j, i, bmp.GetPixel(x2, y2));
}
}
return newBMP;
}
another one in matlab:
scale = [2 2];
oldSize = size(inputImage);
newSize = max(floor(scale.*oldSize(1:2)),1);
rowIndex = min(round(((1:newSize(1))-0.5)./scale(1)+0.5),oldSize(1));
colIndex = min(round(((1:newSize(2))-0.5)./scale(2)+0.5),oldSize(2));
outputImage = inputImage(rowIndex,colIndex,:);
these are all from google, cocknibbler. captcha: even downs