Der rest
protected virtual double calculateAlphaFallout( double f )
{
return f * f * 0.8;
}
protected virtual Bitmap createReflectedBitmap(
Bitmap bmpFramed,
int height )
{
Bitmap bmpResult = new Bitmap( bmpFramed.Width, height );
BitmapData bdS = bmpFramed.LockBits(
new Rectangle( Point.Empty, bmpFramed.Size ),
ImageLockMode.ReadWrite,
PixelFormat.Format32bppArgb );
BitmapData bdD = bmpResult.LockBits(
new Rectangle( Point.Empty, bmpResult.Size ),
ImageLockMode.ReadWrite,
PixelFormat.Format32bppArgb );
unchecked
{
unsafe
{
int nWidthInPixels = bdD.Width * 4;
for ( int y = height-1 ; y >= 0 ; y-- )
{
byte alpha = (byte)(255 * calculateAlphaFallout( (double)(height - y) / _
height ));
Pixel* pS = (Pixel*)bdS.Scan0.ToPointer() + bdS.Width * (bdS.Height - y - _
FrameWidth - 1);
Pixel* pD = (Pixel*)bdD.Scan0.ToPointer() + bdD.Width * y;
for ( int x = bdD.Width ; x > 0 ; x--, pD++, pS++ )
{
int R = gaussBlur( &pS->R, nWidthInPixels );
int G = gaussBlur( &pS->G, nWidthInPixels );
int B = gaussBlur( &pS->B, nWidthInPixels );
pD->R = (byte)((R * 3 + G * 2 + B * 2) / 7);
pD->G = (byte)((R * 2 + G * 3 + B * 2) / 7);
pD->B = (byte)((R * 2 + G * 2 + B * 3) / 7);
pD->A = alpha;
}
}
}
}
bmpFramed.UnlockBits( bdD );
bmpResult.UnlockBits( bdD );
return bmpResult;
}
public static Size adaptProportionalSize(
Size szMax,
Size szReal )
{
int nWidth;
int nHeight;
double sMaxRatio;
double sRealRatio;
if ( szMax.Width < 1 || szMax.Height < 1 || szReal.Width < 1 || _
szReal.Height < 1 )
return Size.Empty;
sMaxRatio = (double)szMax.Width / (double)szMax.Height;
sRealRatio = (double)szReal.Width / (double)szReal.Height;
if ( sMaxRatio < sRealRatio )
{
nWidth = Math.Min( szMax.Width, szReal.Width );
nHeight = (int)Math.Round( nWidth / sRealRatio );
}
else
{
nHeight = Math.Min( szMax.Height, szReal.Height );
nWidth = (int)Math.Round( nHeight * sRealRatio );
}
return new Size( nWidth, nHeight );
}
} 0 |