Przeglądaj źródła

BGR to RGB function

svn path=/trunk/mcs/; revision=19920
Alexandre Pigolkine 22 lat temu
rodzic
commit
e667d1c4ea

+ 19 - 0
mcs/class/System.Drawing/System.Drawing.Imaging/BitmapData.cs

@@ -78,5 +78,24 @@ namespace System.Drawing.Imaging
 				stride = value;
 			}
 		}
+		
+		internal unsafe void swap_red_blue_bytes () 
+		{
+			byte *start = (byte *) (void *) this.Scan0;
+			int stride = this.Stride;
+			for (int line = 0; line < this.Height; line++){
+				// Exchange red <=> blue bytes
+//				fixed (byte *pbuf = start) {
+					byte* curByte = start;
+					for (int i = 0; i < this.Width; i++) {
+						byte t = *(curByte+2);
+						*(curByte+2) = *curByte;
+						*curByte = t;
+						curByte += 3;
+					}
+//				}
+				start += stride;
+			}
+		}
 	}
 }