Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package imagefinal;
- import java.awt.image.BufferedImage;
- import javax.imageio.ImageIO;
- import java.io.File;
- import java.io.IOException;
- /**
- *
- * @author nickd
- */
- public class Image {
- private BufferedImage img;
- public Image(File file)
- {
- try
- {
- BufferedImage img;
- img = ImageIO.read(file);
- }
- catch (IOException e)
- {
- }
- }
- public BufferedImage getImage()
- {
- return img;
- }
- public void toGrayScale()
- {
- for(int i = 0; i < img.getWidth(); i++)
- {
- for(int j = 0; j < img.getHeight(); j++)
- {
- rgbaToGray(i);
- rgbaToGray(j);
- img.getRGB(i, j);
- int pixelRGB = img.getRGB(i, j);
- int pixelGray = rgbaToGray(pixelRGB);
- img.setRGB(i,j, pixelGray);
- }
- }
- }
- public boolean addFrame(File frame)
- {
- BufferedImage img2 = null;
- try
- {
- img2 = ImageIO.read(frame);
- }
- catch (IOException e)
- {
- }
- if(img.getHeight() < img2.getHeight())
- {
- return false;
- }
- if(img.getWidth() < img2.getWidth())
- {
- return false;
- }
- if(img.getWidth() > img2.getWidth() || img.getHeight() > img2.getHeight())
- {
- }
- return true;
- }
- public boolean addSticker(File sticker)
- {
- return true;
- }
- public void cartoonify()
- {
- }
- private int rgbaToGray(int rgba)
- {
- int r = PixelColor.getRedChannel(rgba);
- int g = PixelColor.getGreenChannel(rgba);
- int b = PixelColor.getBlueChannel(rgba);
- int res = (int) (r+g+b/3 + 0.5);
- return rgba;
- }
- private void applyOverlay(BufferedImage overlay)
- {
- }
- private void clusterPixels(int[] clusterColors, int[][] clusterMember)
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement