DisplayResampleImage.cpp revision a60aa561f1dd9095f0838463d71f644aedd06606
/** @file
* Image resampling code, used for snapshot thumbnails.
*/
/*
* Copyright (C) 2009 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*
* Based on gdImageCopyResampled from libgd.
* Original copyright notice follows:
Portions copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
Pierre-Alain Joye (pierre@libgd.org).
Permission has been granted to copy, distribute and modify gd in
any context without fee, including a commercial application,
provided that this notice is present in user-accessible supporting
documentation.
This does not affect your ownership of the derived work itself, and
the intent is to assure proper credit for the authors of gd, not to
interfere with your productive use of gd. If you have questions,
ask. "Derived works" includes all programs that utilize the
library. Credit must be given in user-accessible documentation.
This software is provided "AS IS." The copyright holders disclaim
all warranties, either express or implied, including but not
limited to implied warranties of merchantability and fitness for a
particular purpose, with respect to this code and accompanying
documentation.
*/
/*
*
* @todo Simplify: Offsets of images are 0,0 => no dstX, dstY, srcX, srcY;
* Screenshot has no alpha channel => no processing of alpha byte.
*/
/* 2.0.10: cast instead of floor() yields 35% performance improvement.
Thanks to John Buckman. */
/*#define floor2(exp) floor(exp)*/
typedef uint8_t *gdImagePtr;
{
}
{
}
#define gdAlphaMax 127
#define gdAlphaOpaque 0
#define gdAlphaTransparent 127
#define gdRedMax 255
#define gdGreenMax 255
#define gdBlueMax 255
#define gdTrueColorGetBlue(c) ((c) & 0x0000FF)
#define gdTrueColorAlpha(r, g, b, a) (((a) << 24) + \
((r) << 16) + \
((g) << 8) + \
(b))
{
int x, y;
{
(double) dstH;
{
double spixels = 0;
do
{
double yportion;
{
{
}
}
{
}
else
{
yportion = 1.0;
}
do
{
double xportion;
double pcontribution;
int p;
{
{
}
}
{
}
else
{
xportion = 1.0;
}
/* 2.08: previously srcX and srcY were ignored.
Andrew Pattison */
p = gdImageGetTrueColorPixel (src,
sx += 1.0;
}
sy += 1.0;
}
if (spixels != 0.0)
{
}
/* Clamping to allow for rounding errors above */
if (red > 255.0)
{
red = 255.0;
}
if (green > 255.0)
{
green = 255.0;
}
if (blue > 255.0)
{
blue = 255.0;
}
if (alpha > gdAlphaMax)
{
alpha = gdAlphaMax;
}
x, y,
gdTrueColorAlpha ((int) red,
(int) green,
}
}
}
/* Fast interger implementation for 32 bpp bitmap scaling.
* Use fixed point values * 16.
*/
typedef int32_t FIXEDPOINT;
#define FIXEDPOINT_TO_INT(v) (int)((v) >> 4)
#define FIXEDPOINT_FLOOR(v) ((v) & ~0xF)
#define FIXEDPOINT_FRACTION(v) ((v) & 0xF)
/* For 32 bit source only. */
int iDeltaLine,
{
int x, y;
for (y = 0; y < dstH; y++)
{
for (x = 0; x < dstW; x++)
{
do
{
{
{
}
}
{
}
else
{
}
do
{
int p;
{
{
}
}
{
}
else
{
}
/* Color depth specific code begin */
/* Color depth specific code end */
if (spixels != 0)
{
}
/* Clamping to allow for rounding errors above */
if (red > 255)
{
red = 255;
}
if (green > 255)
{
green = 255;
}
if (blue > 255)
{
blue = 255;
}
x, y,
dstW);
}
}
}