Modified reference blending algorithm.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@519 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2003-04-22 23:16:57 +00:00
parent 4128461aee
commit fb1ca482a7
2 changed files with 23 additions and 1 deletions

View File

@ -312,12 +312,27 @@ void Image::Blend( const Image &image, int transparency ) const
{
assert( width == image.width && height == image.height && colours == image.colours );
if ( !blend_buffer )
{
blend_buffer = new unsigned int[size];
unsigned int *pb = blend_buffer;
JSAMPLE *p = buffer;
while( p < (buffer+size) )
{
*pb++ = (unsigned int)((*p++)<<8);
}
}
JSAMPLE *psrc = image.buffer;
JSAMPLE *pdest = buffer;
unsigned int *pblend = blend_buffer;
while( pdest < (buffer+size) )
{
*pdest++ = (JSAMPLE)(((*pdest * (100-transparency))+(*psrc++ * transparency))/100);
*pblend = (unsigned int)(((*pblend * (100-transparency))+(((*psrc++)<<8) * transparency))/100);
*pdest++ = (JSAMPLE)((*pblend++)>>8);
}
}

View File

@ -61,11 +61,15 @@ protected:
JSAMPLE *buffer;
bool our_buffer;
protected:
mutable unsigned int *blend_buffer;
public:
Image( const char *filename )
{
ReadJpeg( filename );
our_buffer = true;
blend_buffer = 0;
}
Image( int p_width, int p_height, int p_colours, JSAMPLE *p_buffer=0 )
{
@ -84,6 +88,7 @@ public:
our_buffer = false;
buffer = p_buffer;
}
blend_buffer = 0;
}
Image( const Image &p_image )
{
@ -94,6 +99,7 @@ public:
buffer = new JSAMPLE[size];
memcpy( buffer, p_image.buffer, size );
our_buffer = true;
blend_buffer = 0;
}
~Image()
{
@ -101,6 +107,7 @@ public:
{
delete[] buffer;
}
delete[] blend_buffer;
}
inline int Width() { return( width ); }