PC Review


Reply
Thread Tools Rate Thread

Bitmap upload from ppc to web server

 
 
willis
Guest
Posts: n/a
 
      15th Mar 2005
Hi, guys

I have spent the whole week to look for how to upload image from pocket
pc to web server, but still couldn't find a solution. Can anyone please
help?

My situation is
I download a GIF file from web server and display in a picturebox on a
I-mate ppc(This part is done), then the user will add some signs or
draw the notes or icons in the image, finally I would like to upload
this image back to web server (doesn't matter by HTTP, SOCKET, FTP,web
services, DIME, as long as it can work)

My idea is
the GIF file size is 512 x 512, when I tried to save the picturebox
image as a physical bitmap file in the ppc(using the MS Save Bitmap
example,http://www.microsoft.com/downloads/d...displaylang=en),
it takes more then 3 minutes to finish, and the size is about 1.6MB.
So, I'm thinking maybe I could directly send the Bitmap
object(picturebox.image) to the web server, instead of saving as a
local file.

I tried to upload the Bitmap object to web server? I couldn't find a
way to serizalize it to a stream or byte array.
Then I tried to use the DIME and WSE2 to send the image as a DIME
attachment, but don't know how to do it.

Please correct me if I'm not in the right track, or please give me any
idea how to upload the Bitmap object to the server.

Thanks a lot!

Willis

 
Reply With Quote
 
 
 
 
Guest
Posts: n/a
 
      15th Mar 2005
Search the archives. Alex Feinman has posted a link to a sample. A search
string like 'Feinman File Upload' works well.

-Chris


"willis" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi, guys
>
> I have spent the whole week to look for how to upload image from pocket
> pc to web server, but still couldn't find a solution. Can anyone please
> help?
>
> My situation is
> I download a GIF file from web server and display in a picturebox on a
> I-mate ppc(This part is done), then the user will add some signs or
> draw the notes or icons in the image, finally I would like to upload
> this image back to web server (doesn't matter by HTTP, SOCKET, FTP,web
> services, DIME, as long as it can work)
>
> My idea is
> the GIF file size is 512 x 512, when I tried to save the picturebox
> image as a physical bitmap file in the ppc(using the MS Save Bitmap
> example,http://www.microsoft.com/downloads/d...displaylang=en),
> it takes more then 3 minutes to finish, and the size is about 1.6MB.
> So, I'm thinking maybe I could directly send the Bitmap
> object(picturebox.image) to the web server, instead of saving as a
> local file.
>
> I tried to upload the Bitmap object to web server? I couldn't find a
> way to serizalize it to a stream or byte array.
> Then I tried to use the DIME and WSE2 to send the image as a DIME
> attachment, but don't know how to do it.
>
> Please correct me if I'm not in the right track, or please give me any
> idea how to upload the Bitmap object to the server.
>
> Thanks a lot!
>
> Willis
>



 
Reply With Quote
 
chris-s@mailcity.com
Guest
Posts: n/a
 
      15th Mar 2005
Try the following, works for us, sorry about the 'indenting'!!

Chris


public bool UploadFileBinary(string localFile, string uploadUrl)
{
BinaryReader rdr = null;
byte[] data = null;
try
{
rdr = new BinaryReader(File.OpenRead(localFile));
data = rdr.ReadBytes((int)rdr.BaseStream.Length);
}
catch(IOException ioex)
{
System.Windows.Forms.MessageBox.Show(ioex.ToString(), "File Open
Failed");
return false;
}


// Make sure the url is properly escaped. Uri class takes care of
that
Uri uri = new Uri(uploadUrl);


HttpWebRequest req = HttpWebRequest.Create(uri) as HttpWebRequest;
req.Method = "PUT";

// For large files (> 50KB) you may want to uncomment the next line
//req.SendChunked = true;
req.ContentLength = data.Length;
Stream reqStream = null;
try
{
reqStream = req.GetRequestStream();
}
catch(WebException we)
{
System.Windows.Forms.MessageBox.Show("Error!
\n\r\n\r"+we.ToString());
return false;
}
reqStream.Write(data, 0, data.Length);
reqStream.Close();
HttpWebResponse resp = null;
try
{
resp = req.GetResponse() as HttpWebResponse;
}
catch (WebException we2)
{
System.Windows.Forms.MessageBox.Show("Error!
\n\r\n\r"+we2.ToString());

return false;
}
HttpStatusCode code = resp.StatusCode;
rdr.Close();
//System.Windows.Forms.MessageBox.Show("Request succeeded: " +
code.ToString() );
return true;
}

 
Reply With Quote
 
=?Utf-8?B?WXZlcyBab3V6b3VhbWJl?=
Guest
Posts: n/a
 
      15th Mar 2005
First of all you want to compress your images before you upload them to the
server, I think the reason for doing this is obvious. I personaly prefer
Exceed Zip product (http://www.xceedsoft.com/products/ZipNetCF/index.aspx)
for compression. Opon compressing the image file, you will obtain a tream
that can be uploaded to a server as a byte array (using a web service) .

"willis" wrote:

> Hi, guys
>
> I have spent the whole week to look for how to upload image from pocket
> pc to web server, but still couldn't find a solution. Can anyone please
> help?
>
> My situation is
> I download a GIF file from web server and display in a picturebox on a
> I-mate ppc(This part is done), then the user will add some signs or
> draw the notes or icons in the image, finally I would like to upload
> this image back to web server (doesn't matter by HTTP, SOCKET, FTP,web
> services, DIME, as long as it can work)
>
> My idea is
> the GIF file size is 512 x 512, when I tried to save the picturebox
> image as a physical bitmap file in the ppc(using the MS Save Bitmap
> example,http://www.microsoft.com/downloads/d...displaylang=en),
> it takes more then 3 minutes to finish, and the size is about 1.6MB.
> So, I'm thinking maybe I could directly send the Bitmap
> object(picturebox.image) to the web server, instead of saving as a
> local file.
>
> I tried to upload the Bitmap object to web server? I couldn't find a
> way to serizalize it to a stream or byte array.
> Then I tried to use the DIME and WSE2 to send the image as a DIME
> attachment, but don't know how to do it.
>
> Please correct me if I'm not in the right track, or please give me any
> idea how to upload the Bitmap object to the server.
>
> Thanks a lot!
>
> Willis
>
>

 
Reply With Quote
 
Willis
Guest
Posts: n/a
 
      16th Mar 2005
Thank you so much for all of your help!

I got flu today and really don't have energy to try it tonight, will
let you guys know tomorrow.

However, all the solutions mentioned have to convert the Bitmap Object
into a physical file before uploading. In my case, it takes more than
3 minutes to save the image as a Bitmap file on the PDA, and I don't
think it's a good way to do it. Could anyone please point out a better
way to deal with such situation? I'm really appreciated for that!

Cheers

Willis


Yves Zouzouambe <(E-Mail Removed)> wrote in message
news:<7CBA37C5-87B1-420B-A84E-(E-Mail Removed)>...
> First of all you want to compress your images before you upload them to the
> server, I think the reason for doing this is obvious. I personaly prefer
> Exceed Zip product (http://www.xceedsoft.com/products/ZipNetCF/index.aspx)
> for compression. Opon compressing the image file, you will obtain a tream
> that can be uploaded to a server as a byte array (using a web service) .
>
> "willis" wrote:
>
> > Hi, guys
> >
> > I have spent the whole week to look for how to upload image from pocket
> > pc to web server, but still couldn't find a solution. Can anyone please
> > help?
> >
> > My situation is
> > I download a GIF file from web server and display in a picturebox on a
> > I-mate ppc(This part is done), then the user will add some signs or
> > draw the notes or icons in the image, finally I would like to upload
> > this image back to web server (doesn't matter by HTTP, SOCKET, FTP,web
> > services, DIME, as long as it can work)
> >
> > My idea is
> > the GIF file size is 512 x 512, when I tried to save the picturebox
> > image as a physical bitmap file in the ppc(using the MS Save Bitmap
> > example,http://www.microsoft.com/downloads/d...displaylang=en),
> > it takes more then 3 minutes to finish, and the size is about 1.6MB.
> > So, I'm thinking maybe I could directly send the Bitmap
> > object(picturebox.image) to the web server, instead of saving as a
> > local file.
> >
> > I tried to upload the Bitmap object to web server? I couldn't find a
> > way to serizalize it to a stream or byte array.
> > Then I tried to use the DIME and WSE2 to send the image as a DIME
> > attachment, but don't know how to do it.
> >
> > Please correct me if I'm not in the right track, or please give me any
> > idea how to upload the Bitmap object to the server.
> >
> > Thanks a lot!
> >
> > Willis
> >
> >

 
Reply With Quote
 
=?Utf-8?B?WXZlcyBaLg==?=
Guest
Posts: n/a
 
      16th Mar 2005
The Exceed's solution should allow you to work with your images in memory
(leveraging MemoryStream or equivalent), just make sure you have enough
memory on your device. You will also want to pay extra attention with your
application's memory management as it sounds like you will be using a lot of
it. Look at the Garbage collection documentation to see how you can leverage
it or simply be very disciplined in your code by destroying reference type
variables as soon as you are done using them.

Thanks,

Yves.

"Willis" wrote:

> Thank you so much for all of your help!
>
> I got flu today and really don't have energy to try it tonight, will
> let you guys know tomorrow.
>
> However, all the solutions mentioned have to convert the Bitmap Object
> into a physical file before uploading. In my case, it takes more than
> 3 minutes to save the image as a Bitmap file on the PDA, and I don't
> think it's a good way to do it. Could anyone please point out a better
> way to deal with such situation? I'm really appreciated for that!
>
> Cheers
>
> Willis
>
>
> Yves Zouzouambe <(E-Mail Removed)> wrote in message
> news:<7CBA37C5-87B1-420B-A84E-(E-Mail Removed)>...
> > First of all you want to compress your images before you upload them to the
> > server, I think the reason for doing this is obvious. I personaly prefer
> > Exceed Zip product (http://www.xceedsoft.com/products/ZipNetCF/index.aspx)
> > for compression. Opon compressing the image file, you will obtain a tream
> > that can be uploaded to a server as a byte array (using a web service) .
> >
> > "willis" wrote:
> >
> > > Hi, guys
> > >
> > > I have spent the whole week to look for how to upload image from pocket
> > > pc to web server, but still couldn't find a solution. Can anyone please
> > > help?
> > >
> > > My situation is
> > > I download a GIF file from web server and display in a picturebox on a
> > > I-mate ppc(This part is done), then the user will add some signs or
> > > draw the notes or icons in the image, finally I would like to upload
> > > this image back to web server (doesn't matter by HTTP, SOCKET, FTP,web
> > > services, DIME, as long as it can work)
> > >
> > > My idea is
> > > the GIF file size is 512 x 512, when I tried to save the picturebox
> > > image as a physical bitmap file in the ppc(using the MS Save Bitmap
> > > example,http://www.microsoft.com/downloads/d...displaylang=en),
> > > it takes more then 3 minutes to finish, and the size is about 1.6MB.
> > > So, I'm thinking maybe I could directly send the Bitmap
> > > object(picturebox.image) to the web server, instead of saving as a
> > > local file.
> > >
> > > I tried to upload the Bitmap object to web server? I couldn't find a
> > > way to serizalize it to a stream or byte array.
> > > Then I tried to use the DIME and WSE2 to send the image as a DIME
> > > attachment, but don't know how to do it.
> > >
> > > Please correct me if I'm not in the right track, or please give me any
> > > idea how to upload the Bitmap object to the server.
> > >
> > > Thanks a lot!
> > >
> > > Willis
> > >
> > >

>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
upload multiple image to server from remote server RichB Microsoft ASP .NET 4 20th Mar 2008 01:58 AM
FTP upload to Server windsurferLA Microsoft Excel Discussion 1 19th Dec 2005 07:42 AM
Convert bitmap to byte array for upload via webservice =?Utf-8?B?VGltIEpvaG5zb24=?= Microsoft Dot NET Compact Framework 2 19th Jul 2005 01:04 AM
Upload file in Bitmap object David Microsoft ASP .NET 2 15th Dec 2004 09:51 AM
upload bitmap - problem with postback aaapaul Microsoft ASP .NET 1 27th Oct 2004 01:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:16 AM.