Browse Source

Fix an error

phoebus118 17 years ago
parent
commit
ab3d7fccb5
1 changed files with 12 additions and 6 deletions
  1. 12 6
      SDL_Extensions.cpp

+ 12 - 6
SDL_Extensions.cpp

@@ -597,9 +597,12 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
 							case 255:
 								break;
 							default:
-								p[0] = ((((Uint32)tbc.r-(Uint32)p[0])*(Uint32)tbc.unused) + p[0]) & 0xFF;
-								p[1] = ((((Uint32)tbc.g-(Uint32)p[1])*(Uint32)tbc.unused) + p[1]) & 0xFF;
-								p[2] = ((((Uint32)tbc.b-(Uint32)p[2])*(Uint32)tbc.unused) + p[2]) & 0xFF;
+								p[0] = ((((Uint32)tbc.r-(Uint32)p[0])*(Uint32)tbc.unused) >> 8 + p[0]) & 0xFF;
+								p[1] = ((((Uint32)tbc.g-(Uint32)p[1])*(Uint32)tbc.unused) >> 8 + p[1]) & 0xFF;
+								p[2] = ((((Uint32)tbc.b-(Uint32)p[2])*(Uint32)tbc.unused) >> 8 + p[2]) & 0xFF;
+								//p[0] = ((Uint32)tbc.unused*(Uint32)p[0] + (Uint32)tbc.r*(Uint32)(255-tbc.unused))>>8; //red 
+								//p[1] = ((Uint32)tbc.unused*(Uint32)p[1] + (Uint32)tbc.g*(Uint32)(255-tbc.unused))>>8; //green 
+								//p[2] = ((Uint32)tbc.unused*(Uint32)p[2] + (Uint32)tbc.b*(Uint32)(255-tbc.unused))>>8; //blue 
 								break;
 						}
 					}
@@ -627,9 +630,12 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
 							case 255:
 								break;
 							default:
-								p[2] = ((((Uint32)tbc.r-(Uint32)p[2])*(Uint32)tbc.unused) + p[2]) & 0xFF;
-								p[1] = ((((Uint32)tbc.g-(Uint32)p[1])*(Uint32)tbc.unused) + p[1]) & 0xFF;
-								p[0] = ((((Uint32)tbc.b-(Uint32)p[0])*(Uint32)tbc.unused) + p[0]) & 0xFF;
+								//p[2] = ((Uint32)tbc.unused*(Uint32)p[2] + (Uint32)tbc.r*(Uint32)(255-tbc.unused))>>8; //red 
+								//p[1] = ((Uint32)tbc.unused*(Uint32)p[1] + (Uint32)tbc.g*(Uint32)(255-tbc.unused))>>8; //green 
+								//p[0] = ((Uint32)tbc.unused*(Uint32)p[0] + (Uint32)tbc.b*(Uint32)(255-tbc.unused))>>8; //blue 
+								p[2] = ((((Uint32)tbc.r-(Uint32)p[2])*(Uint32)tbc.unused) >> 8 + p[2]) & 0xFF;
+								p[1] = ((((Uint32)tbc.g-(Uint32)p[1])*(Uint32)tbc.unused) >> 8 + p[1]) & 0xFF;
+								p[0] = ((((Uint32)tbc.b-(Uint32)p[0])*(Uint32)tbc.unused) >> 8 + p[0]) & 0xFF;
 								break;
 						}
 					}