Read image
send width
send height
while(MorePixels){
Take a pixel from getRGB(x,y)
Put a split character
send it
}
here is the JAVA code:
/*
* BTServlet.java
*
* Created on February 12, 2007, 9:45 PM
*/
package servlet;
import java.io.*;
import java.net.*;
import java.awt.image.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.imageio.ImageIO;
/**
*
* @author sezer
* @version
*/
public class BTServlet extends HttpServlet {
/** Processes requests for both HTTP
GET
and POST
methods.* @param request servlet request
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
BufferedReader reader = request.getReader();
String msg = reader.readLine();
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
BufferedImage bufImg=null;
try{
File f = new File("C:\\picture.png");
bufImg = ImageIO.read(f);
}
catch(IOException e){
e.printStackTrace();
}
int w = bufImg.getWidth();
int h = bufImg.getHeight();
System.out.println("width:"+w);
System.out.println("height:"+h);
out.print(w+"@"+h+"n");
for(int i = 0 ;i LT h;i++){
for(int j=0;j LT w;j++){
out.print(bufImg.getRGB(j,i)+"?");
}
}
out.flush();
out.close();
}
}
LT : is '<'
No comments:
Post a Comment