Advertisement
Guest User

Untitled

a guest
Feb 14th, 2013
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.38 KB | None | 0 0
  1. /*******************************************************************************
  2.  
  3. INTEL CORPORATION PROPRIETARY INFORMATION
  4. This software is supplied under the terms of a license agreement or nondisclosure
  5. agreement with Intel Corporation and may not be copied or disclosed except in
  6. accordance with the terms of that agreement
  7. Copyright(c) 2012 Intel Corporation. All Rights Reserved.
  8.  
  9. *******************************************************************************/
  10. using UnityEngine;
  11. using System;
  12. public class ShadowHandMod: MonoBehaviour {
  13.    
  14.  
  15.    
  16.     public void ProcessTexture(Texture2D handImage,int[] labels,byte[] labelmap){
  17.                
  18.         Color32[] pixels=handImage.GetPixels32(0);
  19.         for (int y=0, yy1=0, yy2=(handImage.height-1)*handImage.width;y<handImage.height;y++,yy1+=handImage.width,yy2-=handImage.width) {
  20.             for (int x=0;x<handImage.width;x++) {
  21.                 int pixel=labelmap[yy1+x];
  22.                 pixels[yy2+(handImage.width-1-x)]=new Color32(0,0,0,(byte)((pixel==labels[1] || pixel==labels[2])?160:0));
  23.             }
  24.         }
  25.         handImage.SetPixels32 (pixels, 0);
  26.         handImage.Apply();
  27.         renderer.material.mainTexture = handImage;
  28.         //return handImage;
  29.                
  30.     }
  31.    
  32.     public void ZeroImage(Texture2D image) {
  33.         Color32[] pixels=image.GetPixels32(0);
  34.         for (int x=0;x<image.width*image.height;x++) pixels[x]=new Color32(255,255,255,128);
  35.         image.SetPixels32(pixels, 0);
  36.         image.Apply();
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement