Tuesday, April 26, 2005

Aisa lagta hai .......(ummmmm) jane kaisa lagta hai ,i dont know;)

why is everything so funny today i worder ,
is it what it is or is it the way i am looking at things ?

I feel butterflies in my stomach. I think its momentry apprehension.
It will decamp when i take a good sleep. I think it has all got to do abt me going home on 5th and i am thrilled that i am going home after 4 months and dad has planned a trip ( probably to some hill station , he said we will hire a Qualis or some bigger SUV for the trip , boy i am excited)
By the way my project is going fine and here is a simple code to send a image to a server ( put ur url in the Connector.Open() ) and simply put a PHP to upload image there.


---------------------------------------------------------------------------------
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.microedition.io.*;
import java.io.*;

public class ImageSend extends MIDlet implements CommandListener
{
private Image img;
private Display display;
private Command exit;
private Command show;
private Form fImage;
private ImageItem iitm;

private Form messF;
private byte data[];

public ImageSend()
{
getImage();
display=Display.getDisplay(this);
fImage=new Form("Some image");
exit=new Command("Exit",Command.SCREEN,1);
show=new Command("Send",Command.SCREEN,1);
iitm=new ImageItem(null,img,ImageItem.LAYOUT_DEFAULT,"Missing");
fImage.append(iitm);

fImage.setCommandListener(this);
fImage.addCommand(exit);
fImage.addCommand(show);
display.setCurrent(fImage);
}
public void startApp()
{


}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command c, Displayable d)
{
if(c==exit)
{
destroyApp(false);
notifyDestroyed();
}
if(c==show)
{
try
{
HttpConnection htt=(HttpConnection)Connector.open("http://192.168.36.200/~parag/linux/temp.php",Connector.READ_WRITE);
htt.setRequestMethod( HttpConnection.POST );
String boundary = "---------------------------7d43722015402c8";

String message = "--"+boundary+"\r\nContent-Disposition: form-data;"+
"name=\"bytes\"; filename=\"camera.png\"\r\nContent-Type: " + "/x-png\r\n\r\n";

byte []messageBody = message.getBytes();
htt.setRequestProperty("content-type", "multipart/form-data; boundary="+boundary);
DataOutputStream out = new DataOutputStream(htt.openOutputStream());
for(int i=0; i < j="0;j<" message="\r\n" messagebody =" message.getBytes();" i="0;" dis="htt.openDataInputStream();" baos="new" ch="dis.read())!="-1)" data="baos.toByteArray();" strb="new" r="0;r
strb.append((char)data[r]);

System.out.println(strb.toString());
//img=Image.createImage(dt,0,dt.length);
//iitm=new ImageItem(null,img,ImageItem.LAYOUT_DEFAULT,"Missing");
messF=new Form(strb.toString());
//messF.append(iitm);
messF.addCommand(exit);
messF.setCommandListener(this);
display.setCurrent(messF);
out.close();
dis.close();
htt.close();
}
catch(Exception e)
{
System.err.println("Msg: " + e.toString());
}
}
}
private void getImage()
{
DataInputStream is=null;
HttpConnection htt=null;
try
{
htt=(HttpConnection)Connector.open("http://192.168.36.200/~parag/linux/dcgui2.png");
int len=(int)htt.getLength();
data=new byte[len];
is=htt.openDataInputStream();
is.readFully(data);
is.close();
htt.close();
}
catch(Exception e)
{
System.out.println("Read Error");
img=null;
}
System.out.println("Image size "+data.length);
img=Image.createImage(data, 0, data.length);
}
}
---------------------------------------------------------------

If buzz me if u dont get the code. I think its pretty simple .

No comments:

Troubleshooting Packet Drops in SolarFlare Onload 10G PCI Card

If you see lots of packet drops in your onload accelerated application even after going the troubleshooting discussion we did over here ,...