package testing1; import java.awt.Color; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.ArrayList; import javax.imageio.ImageIO; public class test2 { static ArrayList l2 = new ArrayList(); public test2() throws IOException { // new test1(); BufferedImage img = ImageIO.read(new File("img0.png")); final int height = img.getHeight(); final int width = img.getWidth(); // int newwidth=width-1; // int newheight=height-1; int countrow = 0; int countcol = 0; int newrow = width - 1; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { if (countrow == newrow) { Color c = new Color(img.getRGB(i, j)); int a = c.getRed(); l2.add(a); } countcol++; } countrow++; } System.out.println("test2col" + countcol); System.out.println("test2row" + countrow); } } code image2 package testing1; import java.awt.Color; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.ArrayList; import javax.imageio.ImageIO; public class test1 { static ArrayList l1 = new ArrayList(); static int height; static int width; public test1() throws IOException { BufferedImage img = ImageIO.read(new File("img2.png")); height = img.getHeight(); width = img.getWidth(); int countrow = 0; int countcol = 0; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Color c = new Color(img.getRGB(i, j)); int a = c.getRed(); l1.add(a); // System.out.println(l1); countcol++; } countrow++; // break; if (countrow == 1) { continue; } else { } break; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)