mirror of
				https://github.com/MaddyThorson/StrawberryBF.git
				synced 2025-11-04 01:41:33 +08:00 
			
		
		
		
	Casting fixes
This commit is contained in:
		@ -394,9 +394,9 @@ namespace Strawberry
 | 
			
		||||
		    {
 | 
			
		||||
		        for (int p = 0, int b = 0; p < len; p++, b += 4)
 | 
			
		||||
		        {
 | 
			
		||||
		            pixels[p].R = (uint8)((int)bytes[b + 0] * (int)bytes[b + 3] / 255);
 | 
			
		||||
		            pixels[p].G = (uint8)((int)bytes[b + 1] * (int)bytes[b + 3] / 255);
 | 
			
		||||
		            pixels[p].B = (uint8)((int)bytes[b + 2] * (int)bytes[b + 3] / 255);
 | 
			
		||||
		            pixels[p].R = (uint8)((int)bytes[b + 0] * bytes[b + 3] / 255);
 | 
			
		||||
		            pixels[p].G = (uint8)((int)bytes[b + 1] * bytes[b + 3] / 255);
 | 
			
		||||
		            pixels[p].B = (uint8)((int)bytes[b + 2] * bytes[b + 3] / 255);
 | 
			
		||||
		            pixels[p].A = bytes[b + 3];
 | 
			
		||||
		        }
 | 
			
		||||
		    }
 | 
			
		||||
@ -404,7 +404,7 @@ namespace Strawberry
 | 
			
		||||
		    {
 | 
			
		||||
		        for (int p = 0, int b = 0; p < len; p++, b += 2)
 | 
			
		||||
		        {
 | 
			
		||||
		            pixels[p].R = pixels[p].G = pixels[p].B = (uint8)((int)bytes[b + 0] * (int)bytes[b + 1] / 255);
 | 
			
		||||
		            pixels[p].R = pixels[p].G = pixels[p].B = (uint8)((int)bytes[b + 0] * bytes[b + 1] / 255);
 | 
			
		||||
		            pixels[p].A = bytes[b + 1];
 | 
			
		||||
		        }
 | 
			
		||||
		    }
 | 
			
		||||
@ -582,10 +582,10 @@ namespace Strawberry
 | 
			
		||||
		    {
 | 
			
		||||
		        if (src.A != 0)
 | 
			
		||||
		        {
 | 
			
		||||
					int r = dest[index + 0];
 | 
			
		||||
					int g = dest[index + 1];
 | 
			
		||||
					int b = dest[index + 2];
 | 
			
		||||
					int a = dest[index + 3];
 | 
			
		||||
					uint8 r = dest[index + 0];
 | 
			
		||||
					uint8 g = dest[index + 1];
 | 
			
		||||
					uint8 b = dest[index + 2];
 | 
			
		||||
					uint8 a = dest[index + 3];
 | 
			
		||||
 | 
			
		||||
		            if (a == 0)
 | 
			
		||||
		            {
 | 
			
		||||
@ -599,16 +599,16 @@ namespace Strawberry
 | 
			
		||||
		                int sa = MUL_UN8(src.A, opacity);
 | 
			
		||||
		                int ra = a + sa - MUL_UN8(a, sa);
 | 
			
		||||
 | 
			
		||||
		                r = (r + (src.R - r) * sa / ra);
 | 
			
		||||
		                g = (g + (src.G - g) * sa / ra);
 | 
			
		||||
		                b = (b + (src.B - b) * sa / ra);
 | 
			
		||||
						a = ra;
 | 
			
		||||
		                r = (uint8)((int)r + ((int)src.R - r) * sa / ra);
 | 
			
		||||
		                g = (uint8)((int)g + ((int)src.G - g) * sa / ra);
 | 
			
		||||
		                b = (uint8)((int)b + ((int)src.B - b) * sa / ra);
 | 
			
		||||
						a = (uint8)ra;
 | 
			
		||||
		            }
 | 
			
		||||
 | 
			
		||||
					dest[index + 0] = (uint8)r;
 | 
			
		||||
					dest[index + 1] = (uint8)g;
 | 
			
		||||
					dest[index + 2] = (uint8)b;
 | 
			
		||||
					dest[index + 3] = (uint8)a;
 | 
			
		||||
					dest[index + 0] = r;
 | 
			
		||||
					dest[index + 1] = g;
 | 
			
		||||
					dest[index + 2] = b;
 | 
			
		||||
					dest[index + 3] = a;
 | 
			
		||||
		        }
 | 
			
		||||
		    }
 | 
			
		||||
		};
 | 
			
		||||
@ -616,8 +616,8 @@ namespace Strawberry
 | 
			
		||||
		[Inline]
 | 
			
		||||
		private static int MUL_UN8(int a, int b)
 | 
			
		||||
		{
 | 
			
		||||
		    var t = (a * b) + 0x80;
 | 
			
		||||
		    return (((t >> 8) + t) >> 8);
 | 
			
		||||
		    int t = (a * b) + 0x80;
 | 
			
		||||
		    return ((t >> 8) + t) >> 8;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -38,6 +38,11 @@ namespace Strawberry
 | 
			
		||||
			A = (uint8)(alpha * 255);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public this()
 | 
			
		||||
		{
 | 
			
		||||
			R = G = B = A = 0;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public float Rf
 | 
			
		||||
		{
 | 
			
		||||
			[Inline]
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user