アットウィキロゴ

ねこ79

package imgx;
 
 
public class pro {
 
 
 
 
    public static void main(String[] args) {
        pro t=new pro();
    }
    pro(){
 
         int h,w;
 
 
        getsize sub8=new getsize();
        sub8.makedata("neko.jpg");
        h=sub8.h;
        w=sub8.w;
 
 
 int[][] memor=new int[h][w]; 
int[][] memog=new int[h][w]; 
int[][] memob=new int[h][w]; 
 
        System.out.println(w+","+h);
 
 
     catchimg sub=new catchimg();
     sub.w=w;
     sub.h=h;
     sub.memor=memor;
     sub.memog=memog;
     sub.memob=memob;
     sub.makedata("neko.jpg");
     memor=sub.memor;
     memog=sub.memog;
     memob=sub.memob;
 
     System.out.println(w+","+h);
 
 
 
 
graph sub4=new graph();
sub4.sampler=memor;
sub4.sampleg=memog;
sub4.sampleb=memob; 
sub4.w=w;
sub4.h=h;
sub4.makedata("den.jpg");
 
 
 
 
 
    }
 
 
 
 
}
 
package imgx;
 
 
import javax.swing.ImageIcon;
 
import java.awt.*; 
import java.awt.image.*; 
import java.net.URL;
import java.net.MalformedURLException;
 
public class getsize {
 
 
Image img;
int red,green,blue; 
 
int mx,nx,m,n; 
int ex,ey; 
String s1,s2,s3,s4; 
URL urlx;
 
int h,w;
 
void makedata(String pic){
 
catchimgx(pic);  
 
} 
 
void catchimgx(String s){ 
 
img = Toolkit.getDefaultToolkit().getImage(s); 
 
ImageIcon icon = new ImageIcon(img);
h = icon.getIconHeight();
w = icon.getIconWidth();
 
 
 
} 
 
 
 
 
 
}
 
 
 
package imgx;
 
import javax.swing.ImageIcon;
 
import java.awt.*; 
import java.awt.image.*; 
import java.net.URL;
import java.net.MalformedURLException;
 
public class catchimg {
 
PixelGrabber pg; 
Color col; 
Image img2;
int red,green,blue; 
 
int mx,nx,m,n; 
int ex,ey; 
String s1,s2,s3,s4; 
URL urlx;
 
int h,w;
 
int w1=2000;
int h1=2000;
int[] pix=new int[h1*w1]; 
int[][] memor=new int[h1][w1]; 
int[][] memog=new int[h1][w1]; 
int[][] memob=new int[h1][w1];  
 
 
 
void makedata(String pic){
 
catchimg(pic);  
 
} 
 
void catchimg(String sp){ 
 
 
    System.out.println(w+","+h+"l"+"999");
 
img2 = Toolkit.getDefaultToolkit().getImage(sp); 
pg = new PixelGrabber(img2,0,0,w,h,pix,0,w); 
 
try{pg.grabPixels();}catch(InterruptedException ie){
System.out.println("a");
} 
 
m=0; 
n=0; 
for(int i=0;i<w*h;i++){ 
int p = pix[i]; 
col=new Color(pix[i]); 
red=col.getRed(); 
green=col.getGreen(); 
blue=col.getBlue(); 
memor[m][n]=red; 
memog[m][n]=green; 
memob[m][n]=blue; 
n=n+1; 
if (n==w)m=m+1; 
if (n==w)n=0; 
} 
 
 
 
} 
 
 
 
 
 
}
 
 
package imgx;
 
 
 
import java.awt.*; 
import java.awt.Color;   
import java.awt.image.*;   
import java.awt.image.BufferedImage;   
import java.io.*;   
import javax.imageio.ImageIO;   
import java.awt.Polygon;
 
class graph{
 
    int h;
    int w;
 
 
int[][] sampler=new int[h][w]; 
int[][] sampleg=new int[h][w]; 
int[][] sampleb=new int[h][w]; 
 
 
void makedata(String file){
 
    int w1,h1,mx,nx;
 
w1=w;
h1=h;    
BufferedImage off = new BufferedImage(w1, h1, BufferedImage.TYPE_INT_BGR);   
Graphics offsc = off.getGraphics();  
 
int z;
offsc.setColor(Color.white);
offsc.fillRect(0,0,w,h);
 
for(mx=0;mx<h;mx++){
for(nx=0;nx<w;nx++){ 
offsc.setColor(new Color(sampler[mx][nx],sampleg[mx][nx],sampleb[mx][nx])); 
offsc.fillRect(nx,mx,1,1);
}
}  
 
 
offsc.dispose(); 
 
try { 
ImageIO.write(off, "jpeg", new File(file)); 
} catch (IOException exception) { exception.printStackTrace(); }     
}   
}
 
最終更新:2016年05月01日 10:01