J2ME:颜色渐变

系统 2015 0

1

      
         1:  
      
      
        import 
      
      javax.microedition.lcdui.Graphics;
    
      
         2:  
      
    
      
         3:  
      
      
        public class 
      
      CrystalRGB {
    
      
         4:  
      
    
      
         5:  
      
      
        public final static void 
      
      drawRGBVRect(Graphics g, 
      
        int 
      
      color, 
      
        int 
      
      x, 
      
        int 
      
      y,
    
      
         6:  
      
      
        int 
      
      width, 
      
        int 
      
      height) {
    
      
         7:  
      
      
        int
      
      [] rgb = getRGBVColor(color, height);
    
      
         8:  
      
      
        for 
      
      (
      
        int 
      
      i = 0; i 

  
      
        
           9:  
        
        
          int 
        
        nTemp = x + width - (i - x);
      
        
          10:  
        
                    nTemp = nTemp > 4 ? 4 : nTemp;
      
        
          11:  
        
                    g.drawRGB(rgb, 0, 4, i, y, nTemp, height, 
        
          true
        
        );
      
        
          12:  
        
                }
      
        
          13:  
        
            }
      
        
          14:  
        
      
        
          15:  
        
        
          public final static int
        
        [] getRGBVColor(
        
          int 
        
        color, 
        
          int 
        
        h) {
      
        
          16:  
        
        
          int
        
        [] rgb;
      
        
          17:  
        
        
          int 
        
        RGB_L = h;
      
        
          18:  
        
        
          int 
        
        nRgbData = RGB_L * 4;
      
        
          19:  
        
        
          int 
        
        a;
      
        
          20:  
        
                rgb = 
        
          new int
        
        [nRgbData];
      
        
          21:  
        
      
        
          22:  
        
        
          for 
        
        (
        
          int 
        
        i = 0; i 

  
        
          
            23:  
          
                      a = i;
        
          
            24:  
          
          
            if 
          
          (a > 255) {
        
          
            25:  
          
                          a = 255;
        
          
            26:  
          
                      }
        
          
            27:  
          
          
            int 
          
          col = color | (a 

  
          
            
              28:  
            
                        rgb[i * 4] = col;
          
            
              29:  
            
                        rgb[i * 4 + 1] = col;
          
            
              30:  
            
                        rgb[i * 4 + 2] = col;
          
            
              31:  
            
                        rgb[i * 4 + 3] = col;
          
            
              32:  
            
                    }
          
            
              33:  
            
            
              return 
            
            rgb;
          
            
              34:  
            
                }
          
            
              35:  
            
          
            
              36:  
            
            
              public final static void 
            
            drawRGBSRect(Graphics g, 
            
              int 
            
            color, 
            
              int 
            
            x, 
            
              int 
            
            y,
          
            
              37:  
            
            
              int 
            
            width, 
            
              int 
            
            height) {
          
            
              38:  
            
            
              int
            
            [] rgb = getRGBSColor(color, width);
          
            
              39:  
            
            
              for 
            
            (
            
              int 
            
            by = y; by 

  
            
              
                40:  
              
            
              
                41:  
              
              
                int 
              
              nTemp = y + height - (by - y);
            
              
                42:  
              
            
              
                43:  
              
                          nTemp = nTemp > 4 ? 4 : nTemp;
            
              
                44:  
              
                          g.drawRGB(rgb, 0, width, x, by, width, nTemp, 
              
                true
              
              );
            
              
                45:  
              
                      }
            
              
                46:  
              
            
              
                47:  
              
                  }
            
              
                48:  
              
            
              
                49:  
              
              
                public final static int
              
              [] getRGBSColor(
              
                int 
              
              color, 
              
                int 
              
              h) {
            
              
                50:  
              
              
                int
              
              [] rgb;
            
              
                51:  
              
              
                int 
              
              RGB_L = h;
            
              
                52:  
              
              
                int 
              
              nRgbData = RGB_L * 4;
            
              
                53:  
              
                      rgb = 
              
                new int
              
              [nRgbData];
            
              
                54:  
              
              
                int 
              
              alpha = -127;
            
              
                55:  
              
              
                for 
              
              (
              
                int 
              
              i = 0; i 

  
              
                
                  56:  
                
                            alpha = -127 + i;
              
                
                  57:  
                
                
                  int 
                
                col = color | (128 - alpha 

  
                
                  
                    58:  
                  
                              rgb[i] = col;
                
                  
                    59:  
                  
                              rgb[i + RGB_L] = col;
                
                  
                    60:  
                  
                              rgb[i + RGB_L * 2] = col;
                
                  
                    61:  
                  
                              rgb[i + RGB_L * 3] = col;
                
                  
                    62:  
                  
                          }
                
                  
                    63:  
                  
                  
                    return 
                  
                  rgb;
                
                  
                    64:  
                  
                      }
                
                  
                    65:  
                  
                
                  
                    66:  
                  
                  }
                

J2ME:颜色渐变


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论