SHARE
TWEET

Untitled

a guest Dec 14th, 2019 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package imagefinal;
  7.  
  8. import java.awt.image.BufferedImage;
  9. import javax.imageio.ImageIO;
  10. import java.io.File;
  11. import java.io.IOException;
  12. /**
  13.  *
  14.  * @author nickd
  15.  */
  16. public class Image {
  17.     private BufferedImage img;
  18.    
  19. public Image(File file)
  20. {
  21.  
  22. try
  23. {    
  24.  BufferedImage img;
  25.  
  26.  img = ImageIO.read(file);
  27.  
  28. }
  29.  
  30. catch (IOException e)
  31. {
  32.            
  33. }
  34. }
  35.  
  36. public BufferedImage getImage()
  37. {
  38.     return img;
  39. }
  40.  
  41. public void toGrayScale()
  42. {
  43.    
  44.    for(int i = 0; i < img.getWidth(); i++)
  45.    {
  46.     for(int j = 0; j < img.getHeight(); j++)
  47.     {
  48.        
  49.        rgbaToGray(i);
  50.        rgbaToGray(j);
  51.        
  52.        img.getRGB(i, j);
  53.        
  54.        int pixelRGB = img.getRGB(i, j);
  55.        
  56.        int pixelGray = rgbaToGray(pixelRGB);
  57.        
  58.        img.setRGB(i,j, pixelGray);
  59.    }
  60.    
  61. }
  62.  
  63. }
  64. public boolean addFrame(File frame)
  65. {
  66.     BufferedImage img2 = null;
  67.    
  68. try
  69.  {
  70.      img2 = ImageIO.read(frame);
  71.  }
  72.  
  73. catch (IOException e)
  74. {
  75.    
  76. }
  77.  
  78. if(img.getHeight() < img2.getHeight())
  79. {
  80.   return false;
  81. }
  82.  
  83. if(img.getWidth() < img2.getWidth())
  84. {
  85.     return false;
  86. }
  87.  
  88. if(img.getWidth() > img2.getWidth() || img.getHeight() > img2.getHeight())
  89. {
  90.    
  91. }
  92.     return true;
  93. }
  94.  
  95. public boolean addSticker(File sticker)
  96. {
  97.     return true;
  98. }
  99.  
  100. public void cartoonify()
  101. {
  102.    
  103. }
  104.  
  105. private int rgbaToGray(int rgba)
  106. {
  107.    int r = PixelColor.getRedChannel(rgba);
  108.    
  109.    int g = PixelColor.getGreenChannel(rgba);
  110.    
  111.    int b = PixelColor.getBlueChannel(rgba);
  112.    
  113.    int res = (int) (r+g+b/3 + 0.5);
  114.    
  115.    return rgba;
  116. }
  117.  
  118. private void applyOverlay(BufferedImage overlay)
  119. {
  120.    
  121. }
  122.  
  123. private void clusterPixels(int[] clusterColors, int[][] clusterMember)
  124. {
  125.    
  126. }
  127.  
  128.    
  129. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top