Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Version 1 (dereferenced by index)
- for ( y = Math.Max( 0, Area.y ); y < Area.y + Area.height; y++ ) {
- off_y = y - Area.y;
- ptr = baseptr + y * _line + area_x * 4;
- for ( x = area_x; x < Area.x + Area.width; x++ ) {
- off_x = x - Area.x;
- if ( ptr[3] != 0xFF ) {
- CurrentPixel = _base[i].pixels[off_x, off_y];
- alphaf = CurrentPixel.a;
- if ( alphaf == 1.0f ) {
- ptr[0] = ( byte )( CurrentPixel.b * 255 );
- ptr[1] = ( byte )( CurrentPixel.g * 255 );
- ptr[2] = ( byte )( CurrentPixel.r * 255 );
- ptr[3] = ( byte )( alphaf * 255 );
- } else if ( alphaf != 0.0f ) {
- alpha = ( byte )( alphaf * 255 );
- ptr[3] = alpha > ptr[3] ? alpha : ptr[3];
- ptr[2] = ( byte )( ptr[2] + alphaf * ( ( byte )( CurrentPixel.r * 255 ) - ptr[2] ) );
- ptr[1] = ( byte )( ptr[1] + alphaf * ( ( byte )( CurrentPixel.g * 255 ) - ptr[1] ) );
- ptr[0] = ( byte )( ptr[0] + alphaf * ( ( byte )( CurrentPixel.b * 255 ) - ptr[0] ) );
- }
- }
- ptr += 4;
- }
- }
- // Version 2 (dereferenced directly)
- for ( y = Math.Max( 0, Area.y ); y < Area.y + Area.height; y++ ) {
- off_y = y - Area.y;
- ptr = baseptr + y * _line + area_x * 4;
- for ( x = area_x; x < Area.x + Area.width; x++ ) {
- off_x = x - Area.x;
- if ( ptr[3] != 0xFF ) {
- CurrentPixel = _base[i].pixels[off_x, off_y];
- alphaf = CurrentPixel.a;
- if ( alphaf == 1.0f ) {
- *ptr++ = ( byte )( CurrentPixel.b * 255 );
- *ptr++ = ( byte )( CurrentPixel.g * 255 );
- *ptr++ = ( byte )( CurrentPixel.r * 255 );
- *ptr++ = ( byte )( alphaf * 255 );
- } else if ( alphaf != 0.0f ) {
- alpha = ( byte )( alphaf * 255 );
- *ptr++ = ( byte )( *ptr + alphaf * ( ( byte )( CurrentPixel.b * 255 ) - *ptr ) );
- *ptr++ = ( byte )( *ptr + alphaf * ( ( byte )( CurrentPixel.g * 255 ) - *ptr ) );
- *ptr++ = ( byte )( *ptr + alphaf * ( ( byte )( CurrentPixel.r * 255 ) - *ptr ) );
- *ptr++ = alpha > ptr[3] ? alpha : ptr[3];
- } else {
- ptr += 4;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment