Tons rgb

0 respostas
G

Ola gem estou tentando dividir uma imagem nas tres componentes RGB
e presentala em tons de cada uma destas companentes. mas nao estou conseguindo se alguma puder me ajudar postando um codigo alguma coisa fico muito grato

private int[][] rgb(int imagens[]){
        int argb[][]= new int[4][imagens.length];
        int a[] = new int[imagens.length];
        int r[] = new int[imagens.length];
        int g[] = new int[imagens.length];
        int b[] = new int[imagens.length];
        for(int x = 0; x<=imagens.length-1;x++){
           System.out.println("imagens = "+imagens[x]);
            a[x] =(int)(imagens[x]&0Xff000000)>>24;
           System.out.println("a = "+a[x]);
            r[x] = -(int)(imagens[x]&0Xff0000)>>16;
           System.out.println("r = "+r[x]);
            g[x] = -(int)(imagens[x]&0Xff00)>>8;
           System.out.println("g = "+g[x]);
            b[x] = -(int)(imagens[x]&0Xff);
           System.out.println("b = "+b[x]);
            /*
             *     
              comp[2] = color & 255;b
              color = color >> 8;
              comp[1] = color & 255;g
              color = color >> 8;
              comp[0] = color & 255;r
              color = comp[0];
             */
            
            
        }
        argb[0] = a;
        argb[1] = r;
        argb[2] = g;
        argb[3] = b;
        return argb;
    }

este e o botao que chama o metodo acima que encontara as componentes

private void cmdRGBActionPerformed(java.awt.event.ActionEvent evt) {                                       
// TODO adicione seu código de manipulação aqui:
        Icon tempR, tempG, tempB;
        int height, width;
        height = img.getHeight(this);
        width = img.getWidth(this);
        int imagem[] = new int[width*height];
        int argb[][]= new int[4][imagem.length];
        /*pega os pixels da imagem
         *e o coloca em um vetor de inteiros ARGB
         *A = Transparencia
         *R = Red vermelho
         *G = Gree verde
         *B = Blue Azul
         */
        PixelGrabber PG = new PixelGrabber(img,0,0,width,height,imagem,0,width);
        try{
            PG.grabPixels();
        }catch(InterruptedException e){};
        //pega os pixels da imagem
        //recebe as imagens divididas em transparencia, r,g,b
        argb = rgb(imagem);
        r = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(width,height,argb[1],0,width));
        g = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(width,height,argb[2],0,width));
        b = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(width,height,argb[3],0,width));
       
        //R
        this.setIconImage(r);
        tempR = new ImageIcon(r);
        lblR.setIcon(tempR);
        
        //G
        this.setIconImage(g);
        tempG = new ImageIcon(g);
        lblG.setIcon(tempG);
        
        //B
        this.setIconImage(b);
        tempB = new ImageIcon(b);
        lblB.setIcon(tempB);
      
    }

( estou com problema de criar a imagem com o tom R, g ,b sendo uma imagem para cada tipo de tom)

Criado 7 de julho de 2007
Respostas 0
Participantes 1