diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 1835d59b4..3675f78a5 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -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); } } diff --git a/src/zm_image.h b/src/zm_image.h index 2f2810166..28beae295 100644 --- a/src/zm_image.h +++ b/src/zm_image.h @@ -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 ); }