Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Mobile > Server-side image creation in ASP.NET Mobile Web Application

Thread Tools

Server-side image creation in ASP.NET Mobile Web Application

Posts: n/a

I have to generate an image based on information saved in a DB.
This image needs to contain the draw of a cinema room places. This work has
the objective to implement a Online cinema ticket reservation.

I try this:
Bitmap bitmap = new Bitmap(10,10);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap);

g.DrawLine(new Pen(Color.BurlyWood), 0, 0, 10, 10);

bitmap.Save("image1.png", System.Drawing.Imaging.ImageFormat.Png);
Image1.ImageUrl = Server.MapPath(Session.SessionID + ".png");

But the Save method is not available in .NETCF, and I don't know if this is
the best way to force an image to be visible on the client-side.

Any help to turn around this problem?

Thanx a lot,
Ricardo Veloso
Reply With Quote
Ted Harper
Posts: n/a
On Wed, 20 Oct 2004 03:31:03 -0700, "RicardoVeloso"
<(E-Mail Removed)> wrote:

>I try this:
>Bitmap bitmap = new Bitmap(10,10);
>System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap);
>g.DrawLine(new Pen(Color.BurlyWood), 0, 0, 10, 10);
>bitmap.Save("image1.png", System.Drawing.Imaging.ImageFormat.Png);
>Image1.ImageUrl = Server.MapPath(Session.SessionID + ".png");
>But the Save method is not available in .NETCF, and I don't know if this is
>the best way to force an image to be visible on the client-side.

If you are creating the image on the server side as your post says,
then you shouldn't be worred about what the Compact Framework does or
doesn't support, since the image-generation code is NOT running on the
handheld device. In your web server code (running under the full .Net
Framework) you will be doing more-or-less the same to target a mobile
browser as a "full featured" desktop PC browser.

That is, on the web server you will have a SomeDynamicImage.aspx page
which actually returns a GIF or JPEG image, and you will reference
that inside a mobile image control as something like:

<mobile:Image ID="imgRiskChart" Runat="server"

There are a few things to be careful of when writing this dynamic
image to support mobile devices (and I am assuming you already have
the equivalent dynamic image creation working for full desktop
browsers - if not I highly recommend you do this first, just for ease
of debugging your overall chart creation code):

* You should extend System.Web.UI.Page (rather than MobilePage) for
your dynamic image ASPX, to avoid it being attempted to be processed
by the ASP.Net Mobile framework (which doesn't understand a page
having an image MIME type).

* Your calling page (ie the page with the mobile:image tag referencing
the dynamic image) will need to pass in the image size (X/Y
dimenstions), colour depth, preferred MIME type for output image (eg
GIF, JPG, WBMP), and do this dynamically in the codebehind for each
request, because all handheld devices are different.

* When building/updating the ImageUrl in the mobile:Image control,
you'll also have to manually append the authentication cookie if you
are using forms authentication and cookieless (as you'll probably have
to for good wide mobile device support), since this won't be affixed
to the ImageURL automatically by the framework (and if you don't, the
framework will redirect the image content to the logon page, rather
than your rendering code getting run).

Aside from that stuff, you _should_ be able to get your existing
(non-Mobile) ASP.Net dynamic chart/image code working for mobile
clients pretty quickly.

Hope this helps,
Ted Harper (Sydney, Australia)
Reply With Quote

Thread Tools

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
iPhone4,iPhone3,Ipad,Apple Mobile,Blackberry Mobile,HTC Mobile,LGMobile,Motorola Mobile,Nokia Mobile,Samsung Mobile chen selina C++ 0 07-13-2010 08:53 AM