FRESHERSHOME![]() |
This is a discussion on I want to join two jpg images in java? within the JAVA forums, part of the Languages category; I want to join or concatenate two images(jpg) in java, can anyone tell me............
| |||||||
| Notices |
| JAVA JAVA Discussion Forum, Jave Related help |
![]() |
| | Thread Tools | Display Modes |
|
#1
| |||
| |||
| I want to join or concatenate two images(jpg) in java, can anyone tell me.........
__________________ Powered by Yahoo! |
|
#2
| |||
| |||
| 1- You need to read the image in an array ( read Red, Green, and blue components) public int[][] imreadRed(String path) { // * Buffered Image BufferedImage bi ; // * Raster Raster r = null; // * Image array int [][] image; // * Image Width int imageWidth = 0; // * Image Height int imageHeight = 0; try { bi = ImageIO.read(new File(path)); r = bi.getData(); int[] color = new int[3]; r.getPixel(0, 0, color); imageWidth = bi.getWidth(); imageHeight = bi.getHeight(); } catch (IOException e) { e.printStackTrace(); } image = new int[imageHeight][imageWidth]; for(int i=0; i <imageHeight;i++) for(int j=0; j<imageWidth ; j++) { int[] color = new int[3]; r.getPixel(j,i, color); image[i][j] = color[0]; } return image; } public int[][] imreadGreen(String path) { // * Buffered Image BufferedImage bi ; // * Raster Raster r = null; // * Image array int [][] image; // * Image Width int imageWidth = 0; // * Image Height int imageHeight = 0; try { bi = ImageIO.read(new File(path)); r = bi.getData(); int[] color = new int[3]; r.getPixel(0, 0, color); imageWidth = bi.getWidth(); imageHeight = bi.getHeight(); } catch (IOException e) { e.printStackTrace(); } image = new int[imageHeight][imageWidth]; for(int i=0; i <imageHeight;i++) for(int j=0; j<imageWidth ; j++) { int[] color = new int[3]; r.getPixel(j,i, color); image[i][j] = color[1]; } return image; } public int[][] imreadBlue(String path) { // * Buffered Image BufferedImage bi ; // * Raster Raster r = null; // * Image array int [][] image; // * Image Width int imageWidth = 0; // * Image Height int imageHeight = 0; try { bi = ImageIO.read(new File(path)); r = bi.getData(); int[] color = new int[3]; r.getPixel(0, 0, color); imageWidth = bi.getWidth(); imageHeight = bi.getHeight(); } catch (IOException e) { e.printStackTrace(); } image = new int[imageHeight][imageWidth]; for(int i=0; i <imageHeight;i++) for(int j=0; j<imageWidth ; j++) { int[] color = new int[3]; r.getPixel(j,i, color); image[i][j] = color[2]; } return image; } 2- After reading the 2 iages matrix foramt one big array and use this method to write the image public void imwrite(int [][] image,String path) { BufferedImage bi; int imageWidth; int imageHeight; imageWidth = image[0].length; imageHeight = image.length; bi = buildImage(image); File f2 = new File(path); try { ImageIO.write(bi, "jpg", f2); } catch (IOException e) { e.printStackTrace(); } }
__________________ Powered by Yahoo! |
![]() |
| Tags |
| join, two, jpg, images, java |
| Thread Tools | |
| Display Modes | |
|
|
Sitemap
Jobs by Location: Advertising and Marketing Jobs - IT Software Jobs - Walk-in Jobs - BPO Jobs - Government Jobs - Sales / BD Jobs - Tele Communication Jobs App Programming - Network Admin
Jobs By Location: Jobs in Bangalore - Jobs In India - Jobs in Delhi - Jobs in Hyderabad - Jobs in Kochi - Jobs in Mumbai - Jobs in Trivandrum - Jobs in pune - Jobs in Jonida - Jobs in Chennai - Jobs in Coimbator
Jobs Type: Full Time Jobs - Part Time Jobs
Latest Jobs - Accounting Jobs - Engineering Jobs - IT Jobs - Walkins - How to Face Interview - HR Round Tips - Career Info - Guide For Freshers - Apply for Jobs - Future Studies - Jobs Forums - Freshers IT Software Salary Details