Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- I used this in my OpenGL project , to decode external images & save it as RGB array inside a certain node
- */
- private void assignImage(node n,String src)
- {
- try{
- BufferedImage img=ImageIO.read(new File(src));
- int i,j,r,g,b,rgb;
- n.h=img.getHeight();
- n.w=img.getWidth();
- n.RGB=new int[n.w][n.h][3];
- // int andr=Integer.parseInt("111111110000000000000000",2);
- // int andg=Integer.parseInt("000000001111111100000000",2);
- // int andb=Integer.parseInt("000000000000000011111111",2);
- Color c;
- for( i=0;i<n.w;i++)
- for( j=n.h-1;j>=0;j--)
- {
- rgb=img.getRGB(i, j);
- c=new Color(rgb);
- n.RGB[i][j][0]=c.getRed();
- n.RGB[i][j][1]=c.getGreen();
- n.RGB[i][j][2]=c.getBlue();
- // r= ((rgb & andr )>>16);
- // g= ((rgb & andg )>>8);
- // b= (rgb & andb );
- }
- }catch(Exception e){}
- }
Advertisement
Add Comment
Please, Sign In to add comment