Hello ,
I need help urgently to present my final project of "How to generate real time image (on the fly)to WAP . I am beginner in java language also leaked of knowledged in java.
i used a sevlet tomcat 4.1 as a server and openwave 5.1 as a phone simulator. i have to display the real time image at the simulator but i donn't have any idea to do it.
This is my program to send image from sevlet to openwave:-
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class LApple extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
doPost( req, res );
}
public void doPost (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.addHeader("Cache-Control","no-cache, must-
revalidate");
res.addHeader("Pragma","no-cache");
res.setContentType("text/vnd.wap.wml");
char ch ='"';
String ch2="'";
PrintWriter pw = res.getWriter();
pw.println("
");
pw.println("
");
pw.println("
");
pw.println("Apple for you!");
pw.println("
");
pw.println("
");
pw.println("
");
pw.println("
");
pw.println("
");
pw.println("
"+new Date().toString()+"
");
pw.println("
hould be reloaded every 10 seconds from http://127.0.0.1.
");
pw.println("
");
pw.println("
");
pw.println("
");
}
}
Your program is helpful to convert image to wbmp format but i don't know how to use to get the display in my openwave simulator.
My email is ru5lan@yahoo.com
Somebody who can help me it really save my life.
This program is wore by Mr francois lascelles's
import java.io.*;
import java.lang.*;
import java.awt.*;
import java.awt.Graphics.*;
import java.awt.Graphics2D;
import java.awt.image.*;
import java.awt.geom.*;
import java.util.*;
import javax.swing.*;
public class WBmpRenderer {
// the bitmap
protected BufferedImage iBitmap;
// the context to draw into
protected Graphics2D iGraphicsContext;
// bitmap size
protected byte iWidth;
protected byte iHeight;
// construct with the size of the bitmap
public WBmpRenderer(byte aWidth, byte aHeight)
throws Exception {
iWidth = aWidth;
iHeight = aHeight;
iBitmap = new BufferedImage(
iWidth, iHeight, BufferedImage.TYPE_BYTE_BINARY);
if (iBitmap == null) {
throw new Exception(
"cannot create BufferedImage object");
}
iGraphicsContext = iBitmap.createGraphics();
if (iGraphicsContext == null) {
throw new Exception(
"cannot create Graphics2D object");
}
}
// retreive graphic context to draw stuff into bitmap
public Graphics2D graphicsContext() {
return iGraphicsContext;
}
//
// This send the image to the output in WBMP
// (WIRELESS BITMAP)
//
// WBMP FORMAT:
// BYTE 1 AND BYTE 2 = 0
// BYTE 3 width in pixels
// BYTE 4 height in pixels
// the rest is the pixels (one bit per pixel)
//
public boolean sendToOutput(OutputStream anOut) {
try {
byte byteInOutput = 0;
// write twice "0"
anOut.write(byteInOutput);
anOut.write(byteInOutput);
// output the height and the width
anOut.write(iWidth);
anOut.write(iHeight);
// output the bytes containing the graph
DataBuffer locImageDataBuffer =
iBitmap.getData().getDataBuffer();
int nbElementsInLocImage =
locImageDataBuffer.getSize();
// one by one
for (int count = 0;
count
< nbElementsInLocImage;
++count) {
anOut.write((byte)
locImageDataBuffer.getElem(count));
}
} catch (Exception e) {
return false;
}
return true;
}
/
/ My friend try to continue by wrote this code but
don't know how to display output stream
public static void main(String[] args) throws Exception
{
WBmpRenderer wbmp = new WBmpRenderer((byte)50, (byte)50);
Graphics2D wbmpg2d = wbmp.graphicsContext();
Ellipse2D e = new Ellipse2D.Double(10,10,20,20);
wbmpg2d.setPaint(new Color(200, 200, 200));
wbmpg2d.fill(e);
wbmpg2d.draw(e);
}
}
.
<<Less