Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

turn array to image java

Path is were you want your image to be saved and the color array
is the array you would like to turn into an image
just as an FYI I used this in my college NEA to test outputs for
Neural Network when trainig XOR was very cool would reccomend.

public static void writeImage(String path, int[][] color) {
	BufferedImage image = new BufferedImage(color[0].length, color.length, BufferedImage.TYPE_INT_BGR);
	for (int y = 0; y < color.length; y++) {
		for (int x = 0; x < color[0].length; x++) {
			image.setRGB(x, y, color[y][x]);
		}
	}
	File ImageFile = new File(path);
	try {
		ImageIO.write(image, "png", ImageFile);
	} catch (IOException e) {
		e.printStackTrace();
	}	
}
Comment

PREVIOUS NEXT
Code Example
Java :: Java 17 not showing in linux 
Java :: how to get the width and height of display device in java 
Java :: AndroidManifest.xml file describes the fundamental characteristics of the app and defines each of its components 
Java :: edit xmlns attribute with jaxb marshaller 
Java :: how does java knows where it has stored primitive data type 
Java :: Automatic Code Completion in NetBeans 
Java :: webmvctest vs springboottest 
Java :: jks not found when trying googlenethttptransport 
Java :: como llamar a un metodo static en java 
Java :: For loop in selenium java li 
Java :: java difrence betwen x++ and ++x 
Java :: android java update image dynamically 
Java :: java add backslash into string 
Java :: java declared fields vs fields 
Java :: how to code the overdraft limit in Java 
Java :: model mapper with Page 
Java :: add method in java 
Java :: {1 2 3 4 5 } 
Java :: java optional input for funktions 
Java :: Which of the following is an example of a Method reference? 
Java :: how to find the size of table in java 
Java :: what is this code (long millis=System.currentTimeMillis(); java.sql.Date date=new java.sql.Date(millis); 
Java :: char array substring java 
Java :: equality primitives java 
Java :: find the length of jtextfeild in java 
Java :: convert java code to kotlin online 
Java :: bukkit java get max players 
Java :: how to set edittext color in android 
Java :: java use of super keyword 
Java :: sorting algorithms in java 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =