Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. public void glitchHeightMap(double intensity, String outputName){
  2.  
  3. Pixel pixel2;
  4.  
  5. VectorFunctions v = new VectorFunctions();
  6.  
  7. Color c;
  8.  
  9. try{
  10.  
  11. BufferedImage img = new BufferedImage(picture.getWidth(), picture.getHeight(), BufferedImage.TYPE_INT_RGB);
  12.  
  13. for(int j=0; j<picture.getWidth(); j++){
  14.  
  15. for(int k=0; k<picture.getHeight(); k++){
  16.  
  17. pixel1 = picture.getPixel(j,k);
  18.  
  19. v.setVectorV(pixel1.getRed(),pixel1.getGreen(),pixel1.getBlue());
  20.  
  21. if((k-v.getmagV())>0){
  22.  
  23. for(int i=0;i<(Math.toIntExact(Math.round((v.getmagV()/intensity))));i++){
  24.  
  25. //if((i+2)>(Math.toIntExact(Math.round((v.getmagV()/intensity))))){ //only paints the top pixel
  26.  
  27. c = new Color(pixel1.getRed(), pixel1.getGreen(), pixel1.getBlue());
  28.  
  29. img.setRGB(j,k-i,c.getRGB());
  30.  
  31. //}
  32.  
  33. }
  34.  
  35. }
  36.  
  37. }
  38.  
  39. }f = new File("C:\\...."+outputName+".png");
  40.  
  41. ImageIO.write(img, "PNG", f);
  42.  
  43. }catch(IOException e){
  44.  
  45. e.printStackTrace();
  46.  
  47. }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement