c# - How could I optimize this pixel opacity calculation? -


I for the C # code pixel count ambiguity, it is used in XNA, I can still improve it Have a demonstration?

  public static uint GetPixelForOpacity (uint pixelBackground, uint pixelForeground, uint pixelCanvasAlpha) {byte surfacer = (byte) ((pixelForeground & amp; 0x00FF0000) & gt; & gt; 16); Byte Surgeon = (Byte) ((Pixel Forford & 0x0000FF00) & gt; & gt; 8); Byte Surface B = (Byte) ((Pixel Forford & 0x000000 FF)); Byte source R = (byte) ((; Pixel Background & amp 0x00FF0000) & gt; & gt; 16); Byte sourceG = (byte) ((pixelBackground & amp; 0x0000FF00) & gt; & gt; 8); Byte source B = (byte) ((pixel background and 0x000000 FF)); Camel Never = Surser * Pikselsnvslfa / 256 + Srfsr * (255 - Pikselsnvslfa) / 256; Uint Nevg = Sources * Pikselsnvslfa / 256 + Surfseg * (255 - Pikselsnvslfa) / 256; Uint Nuova Nube = Surseb * Pikselsnvslfa / 256 + Surfasb * (255 - Pikselsnvslfa) / 256; Return (UIT) 255 & lt; & Lt; 24 | New r & lt; & Lt; 16 | New g & lt; & Lt; 8 | Newb; }    

  1. use.
  2. Video cords are made exactly to speed up such operations. Place your pixel data in a Texture2D and draw it on the screen with an appropriate blend mode. It will be too much, very fast, or if you do not want it right on the screen, then for another look.

Comments